<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
<head>
	<title>Extend ServiceController class to change the StartupType of Windows Services - CodeProject</title> 
	<link type="text/css" rel="stylesheet" href="http://s.codeproject.com/App_Themes/Std/Css/CodeProject.min.css?dt=2.5.120528.1">

	
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Description" content="How to control the windows service&#39;s StartupType and extend the functionality of the ServiceController class; Author: Mohamed Sharaf; Updated: 8 Jul 2004; Section: Hardware &amp; System; Chapter: General Reading; Updated: 8 Jul 2004" />
<meta name="Keywords" content=".NET1.0, .NET1.1, VS.NET2003, C#, Windows, Dev, Intermediate,Hardware &amp; System,General Reading,Free source code, tutorials" />
<meta name="Author" content="Mohamed Sharaf" />
<meta name="Rating" content="General" />
<meta name="Robots" content="index, follow, NOODP" />
<meta name="Revisit-After" content="1 days" />
<meta name="application-name" content="The Code Project" />

<meta name="msapplication-navbutton-color" content="#FF9900" />
<meta name="msapplication-tooltip" content="Your Development Resource." />
<meta name="msapplication-starturl" content="http://www.codeproject.com/?pinned=true" />
<meta name="msapplication-task" content="name=Homepage;action-uri=http://www.codeproject.com/;icon-uri=http://www.codeproject.com/favico.ico" />
<meta name="msapplication-task" content="name=Latest Articles;action-uri=http://www.codeproject.com/script/articles/Latest.aspx;icon-uri=http://www.codeproject.com/favico.ico" />
<meta name="msapplication-task" content="name=Questions and Answers;action-uri=http://www.codeproject.com/script/Answers/;icon-uri=http://www.codeproject.com/favico.ico" />
<meta name="msapplication-task" content="name=The Lounge;action-uri=http://www.codeproject.com/Lounge.aspx;icon-uri=http://www.codeproject.com/favico.ico" />

<link rel="dns-prefetch" href="//ajax.googleapis.com" /> 
<link rel="canonical" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start" />


<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - All Topics" href="http://www.codeproject.com/WebServices/ArticleRSS.aspx?cat=1" />
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - MFC/C++" href="http://www.codeproject.com/WebServices/ArticleRSS.aspx?cat=2" />
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - C#" href="http://www.codeproject.com/WebServices/ArticleRSS.aspx?cat=3" />
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - VB.NET" href="http://www.codeproject.com/WebServices/ArticleRSS.aspx?cat=6" />
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - Mobile" href="http://www.codeproject.com/WebServices/ArticleRSS.aspx?cat=18" />
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - ASP.NET" href="http://www.codeproject.com/WebServices/ArticleRSS.aspx?cat=4" />
<link rel="alternate" type="application/rss+xml" title="CodeProject Lounge Postings" href="http://www.codeproject.com/webservices/LoungeRSS.aspx" />
<link rel="search" type="application/opensearchdescription+xml" title="CodeProject" href="http://www.codeproject.com/info/OpenSearch.xml" />

	<base target="_top" />
	<link rel="icon" href="/favicon.ico" type="image/ico" >
<link rel="shortcut icon" href="/favicon.ico"  type="image/ico" >
<link rel="apple-touch-icon" href="/images/FavIcon-Apple.png" type="image/png" >
<script type="text/javascript" language="Javascript">//<![CDATA[
if(top!=self && !/https?:\/\/([a-zA-Z]+\.)?facebook.com\//gi.test(top.location.href))top.location.href=location.href; if(typeof(DemoUrl)!='undefined')document.write(unescape('%3Cme')+'ta http'+'-equiv="re'+'fresh" con'+'tent="1;url='+DemoUrl+unescape('"%3CE'));
function SelfCheck(){ return window.confirm("You are about to reply to your own message. Is this really what you want?");}
function FireNew(elm) { window.location=$(elm).find('a')[0].href;}

function MsgVFrm(MemberID,MsgID,GB,gp,bp,mt){
 if(!GB)document.write("Rate this message: ");
 document.write(unescape("%3Ca href=\"#xx" + MsgID.toString() + "xx\" onclick=\"RateMsg(" + MemberID.toString() + ", " + MsgID.toString() + ","));document.write((GB?"5":"1")+unescape(",0);\"%3E"));
 if(GB) document.write(unescape("%3Cimg height=\"20\" width=\"20\" src=\"/script/Forums/Images/good.png\" alt=\"good\" border=\"0\" align=\"absmiddle\" /%3E "+gp+" "+mt+"%3C/a%3E "));
 else document.write(unescape("%3Cimg height=\"14px\" width=\"14px\" src=\"http://s.codeproject.com/script/Forums/Images/thumbs_down.gif\" alt=\"vote 1\" border=\"0\" align=\"middle\" /%3E%3C/a%3E "));
 if(GB)document.write(" &nbsp;"); else for(var i=1; i<=5;i++)
  document.write(unescape("%3Ca class=\"toolbar nav-link\" href=\"#xx" + MsgID.toString() + "xx\" title=\"vote this message a " + i.toString() + "\" onclick=\"RateMsg(" + MemberID.toString() + ", " + MsgID.toString() + ", " + i.toString() + ",0)\"%3E%3Cb%3E" + i.toString() + "%3C/b%3E%3C/a%3E "));
 document.write(unescape("%3Ca href=\"#xx" + MsgID.toString() + "xx\" onclick=\"RateMsg(" + MemberID.toString() + ", " + MsgID.toString() + ","));document.write((GB?"1":"5")+unescape(",0);\"%3E"));
 if(GB)document.write(unescape("%3Cimg height=\"20\" width=\"20\" src=\"/script/Forums/Images/bad.png\" alt=\"bad\" border=\"0\" align=\"absmiddle\" /%3E "+bp+" "+mt+"%3C/a%3E"));
 else document.write(unescape("%3Cimg height=\"14px\" width=\"14px\" src=\"http://s.codeproject.com/script/Forums/Images/thumbs_up.gif\" border=\"0\" alt=\"vote 5\" align=\"middle\" /%3E%3C/a%3E "));
}

function ReportMsg(userid, msgid, score) {
 if (confirm("Are you sure you want this message removed?"))
  return RateMsg(userid, msgid, score, 0);
 else return false;
}
function RateMsg(memberid, msgid, score, questionId) {
 var req = new XMLHttpRequest();
 req.onreadystatechange = function() {
  if (req.readyState == 4){
   if (req.status == 200){
    var respText = req.responseText;
    var re = new RegExp(unescape("\%3Cdiv\%3E(.*)\%3C/div\%3E"), "g");
    var match = re.exec(respText);
    voteStatus.innerHTML = unescape("%3Cb%3E") + (match&&match.length>1&&match[1])?match[1]:"An error occurred" + unescape("%3C/b%3E");
   } else
    voteStatus.innerHTML = unescape("%3Cb style='color:red'%3EFailed!") + req.statusText + unescape("%3C/b%3E");
  }
 }
 var voteStatus = document.getElementById("MVF" + msgid);
 if (!voteStatus) return;
 voteStatus.innerHTML = unescape("%3Cb style='color:green'%3EVoting...%3C/b%3E");
 var strAction = "/script/Forums/Vote.aspx?js=1&fmid="+memberid.toString()+"&select="+msgid.toString()+"&score="+score.toString()+"&qid="+questionId.toString();
 req.open("GET", strAction, true);
 req.send(null);
  return false;
}
var smoothScroll = true;
var Selected = "-1";
var oldTitle = document.title;
function Pin(elm){
 CloseMsg(Selected);
 Selected=''
 var wrk=elm.parentNode; if(wrk)wrk=wrk.children[0];
 var fc=elm?elm.firstChild:null;
 if (wrk&&!wrk.pinned) {
  OpenMsg(wrk.name, true);wrk.pinned=true;fc.src='http://s.codeproject.com/script/forums/images/pinned.gif';fc.title='Pinned. Click to unpin'
 } else {
  wrk.pinned=false;CloseMsg(wrk.name); fc.src='http://s.codeproject.com/script/forums/images/pin.gif';fc.title='Click to pin message'
 }
 return false;
}
function CloseMsg(msgId) {
 if(!msgId||msgId==''||msgId<0)return;
 var lnk=document.getElementsByName(msgId);
 if(lnk&&lnk.length>0&&lnk[0].pinned)return;
 var hed=document.getElementById('F' + msgId.toString() + '_h0');
 if(hed) hed.className = hed.className.replace("Sel", "UnSel");
 var bdy=document.getElementById('F' + msgId.toString() + '_h1');
 if(bdy) bdy.style.display = 'none';
 if(oldTitle) document.title = oldTitle;
}
function OpenMsg(msgId, keep) {
 if(!msgId||msgId==''||msgId<0)return;
 var bdy=document.getElementById('F' + msgId.toString() + '_h1');
 if(bdy){
  var lnk=document.getElementsByName(msgId);
  if(lnk&&lnk.length>0&&lnk[0].pinned)keep=true;
  if(lnk&&lnk.length>0) { oldTitle=document.title; document.title = lnk[0].innerHTML + ' - CodeProject'; }
  if(keep&&bdy.style.display!='none')return;
  if(bdy.style.display=='none') bdy.style.display='';
  else bdy.style.display = 'none';
 }
 var hed=document.getElementById('F' + msgId.toString() + '_h0');
 if (hed) hed.className = hed.className.replace('UnSel', 'Sel');
 if(bdy&&hed&&bdy.style.display!='none'){
  var webkitWeird=document.documentElement.scrollTop < document.body.scrollTop;
  if (!webkitWeird)document.body.scrollTop = getRealPos(hed, 'Top') - document.body.clientHeight/10;
  EnsureMessageVisible(msgId, true);
 }
}
function EnsureMessageVisible(msgID, bShowTop) {
	var webkitWeird = document.documentElement.scrollTop < document.body.scrollTop;
	var msgHeader = document.getElementById('F' + msgID + '_h0');
	var msgBody = document.getElementById('F' + msgID + '_h1');
	if (!msgBody || !msgHeader) return;
	var scrollContainer = document.documentElement;
	var top = getRealPos(msgHeader, 'Top');
	var bottom = getRealPos(msgBody, 'Top') + msgBody.offsetHeight;
	var scrollTop = webkitWeird? scrollTop = document.body.scrollTop:document.documentElement.scrollTop;
	if (scrollTop > top && !bShowTop) scrollTop = top - scrollContainer.clientHeight / 10;
	if (scrollTop + scrollContainer.clientHeight < bottom) scrollTop = bottom - scrollContainer.clientHeight;
	if (scrollTop > top && bShowTop) scrollTop = top - scrollContainer.clientHeight / 10;
 if (smoothScroll){
  if (webkitWeird) $(document.body).stop().animate({'scrollTop' : scrollTop}, 'fast');
  else $(scrollContainer).stop().animate({'scrollTop' : scrollTop}, 'fast');
 } else {
  if (webkitWeird) document.body.scrollTop = scrollTop;
  else scrollContainer.scrollTop = scrollTop;
 }
}
function getRealPos(i,which) {
	iPos = 0;
	while (i!=null)  {
		iPos += i['offset' + which];
		i = i.offsetParent;
	}
	return iPos;
}
var switchCallback;
function SwitchMessage(e, msgId) {
  if (msgId) msgId=msgId.toString();
  else {
    if(!e)e=window.event;
    var target=e.target?e.target:e.srcElement;
    while(target&&target.className!='message-link')target=target.parentNode;
    if(!target||target.className!='message-link')return;
    if(target.pinned){/*Selected='';*/return false;}
    msgId=target.name;
  }
  CloseMsg(Selected)
  if(Selected==msgId) Selected='';
  else { OpenMsg(msgId, false); Selected=msgId;}
  if (e){if(e.preventDefault)e.preventDefault;else e.returnValue=false;}
    if(switchCallback)switchCallback(null, msgId)
  return false;
}


//]]>
</script>

	
<script type="text/javascript">
  var _comscore = _comscore || [];
  _comscore.push({ c1: "2", c2: "13507173" });
  (function() {
	var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
	s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
	el.parentNode.insertBefore(s, el);
  })();
</script>
<noscript>
  <img src="http://b.scorecardresearch.com/p?c1=2&c2=13507173&cv=2.0&cj=1" id="ctl00_Auditing_ComScore" />
</noscript>



<script type="text/javascript">
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-1735123-1']);
	_gaq.push(['_trackPageview']);
	_gaq.push(['_setDomainName', 'www.codeproject.com']);
	_gaq.push(['_setSessionTimeout', '1200']); 

	(function () {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
	})(); 
</script>


</head>	

<body class="chrome chrome12">




<a href="#Main"><img alt="Click here to Skip to main content" class="access-link" src="/Images/t.gif" /></a>


<div class="page-background">
	<div id="A" class="container-content">

		
		

		

		
		

<div class="container nav-memberbar clearfix">
	<div class="member-stats float-left">8,874,771 members and growing! (50,282 online)</div>
	<div class="float-left"></div>

	<div class="float-right">
		&nbsp;&nbsp;
	</div>

	<div class="float-right">
		

<span class="tooltip member-message">
	<img src="/images/envelope11.gif" width="11px" height="11px" 
		style="vertical-align:bottom;padding-bottom:3px"/>
	<div class="tooltip-flyout small-text">
		
		<div id="ctl00_MemberMenu_Messages_Confirm"><a id="ctl00_MemberMenu_Messages_EmailConfirm" href="/script/Membership/SendConfirmRequest.aspx?rp=%2fArticles%2f7665%2fExtend-ServiceController-class-to-change-the-Start">Your email address needs to be confirmed.</a></div>
	</div>
</span><span id="ctl00_MemberMenu_CurRat" class="tooltip">
				<a id="ctl00_MemberMenu_MyProfile" href="/script/Membership/View.aspx?mid=8126139">quwenchao</a><img src="/Images/arrow-down-16.png" 
					style="width:16px;height:16px;vertical-align:bottom" />
				<div class="tooltip-flyout" style="width:110px !important">
					<div><a id="ctl00_MemberMenu_MySettingsNonSSL" href="http://www.codeproject.com/script/Membership/Modify.aspx">My Settings</a></div>
					<div><a id="ctl00_MemberMenu_MySettings" href="https://www.codeproject.com/script/Membership/Modify.aspx"><img src="/images/secure.png" width="13px" height="14px"  style="vertical-align:middle;border:0">My Settings (SSL)</a></div>
					<div><a id="ctl00_MemberMenu_MyContacts" href="/script/Membership/ListContacts.aspx">My Contact info</a></div>
					<div><a id="ctl00_MemberMenu_MyBookmarks" href="/script/Bookmarks/List.aspx?obtid=2">My Bookmarks</a></div>
					
					<div><a id="ctl00_MemberMenu_MyCodeProject" href="/script/Membership/MyWatchedItems.aspx">My Watched Items</a></div>
					<div><a id="ctl00_MemberMenu_MyArticles" href="/script/Articles/MemberArticles.aspx?amid=8126139">My Articles</a></div>
					<div><a id="ctl00_MemberMenu_MyMessages" href="/script/Forums/Messages.aspx?fmid=8126139">My Messages</a></div>
					<div><a id="ctl00_MemberMenu_MyQuestions" href="/script/Answers/MemberPosts.aspx?tab=questions&amp;mid=8126139&amp;showall=True">My Questions</a></div>
					<div><a id="ctl00_MemberMenu_MyAnswers" href="/script/Answers/MemberPosts.aspx?tab=answers&amp;mid=8126139&amp;showall=True">My Answers</a></div>
					<div><a id="ctl00_MemberMenu_MyComments" href="/script/comments/MemberComments.aspx?mid=8126139">My Comments</a></div>
					
				</div>
			</span><span id="ctl00_MemberMenu_TotalPoints" title="Total reputation points 973" class="member-rep-box silver" style="margin-left:0"><a href="/script/Reputation/List.aspx?mid=8126139">973</a></span>
			&nbsp;
			<a id="ctl00_MemberMenu_Signout" href="/script/Membership/LogOff.aspx?rp=%2fArticles%2f7665%2fExtend-ServiceController-class-to-change-the-Start">Sign out</a>

		
	</div>
</div>
		

		
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td class="page-header"><a href="/"><img id="ctl00_Logo" title="The Code Project" src="http://s.codeproject.com/App_Themes/Std/Img/logo225x90.gif" alt="Home" style="border-width:0px;" /></a></td>
			<td class="page-header" align="right">
				<div class="lqm_ad" lqm_publisher="lqm.codeproject.site"  lqm_zone="ros" lqm_format="728x90" lqm_tags='.NET1.0, .NET1.1, VS.NET2003, C#, Windows, Dev, Intermediate,rating4'></div>
			</td>
		</tr></table>

		<table cellpadding="0" cellspacing="0" class="contrast1-background extended"><tr><td nowrap="nowrap">
			

<div class="navbar clearfix">
<ul id="nav" class="openable">

<li><a id="ctl00_TopNavBar_Home" class="down" href="http://www.codeproject.com">Home</a>


<li><a id="ctl00_TopNavBar_Art" class="down selected" href="/script/Articles/Latest.aspx">Articles</a>

	<ul class="openable">
		<li><a id="ctl00_TopNavBar_ArtTopicList" class="fly last" onmouseover="navBarMenu.ShowMap(this, &#39;siteMap&#39;);" href="/script/Content/SiteMap.aspx">Chapters and Sections<span class="fly-menu">&gt;</span></a><ul id="ctl00_TopNavBar_MapFlyout" class="openable"><li>
				<div id="siteMap" class="tooltip-flyout">
					<img src="/images/animated.gif" style="margin:150px;width:100px;height:100px;" />
				</div>
			</li></ul>
		</li>
		<li><a id="ctl00_TopNavBar_ArtSearch" class="fly break" href="/search.aspx">Search</a></li>
		<li><a id="ctl00_TopNavBar_ArtLatestArts" class="fly" href="/script/Articles/Latest.aspx?at=1,3,7">Latest Articles</a></li>
		<li><a id="ctl00_TopNavBar_ArtLatestTips" class="fly" href="/script/Articles/Latest.aspx?at=6">Latest Tips/Tricks</a></li>
		<li><a id="ctl00_TopNavBar_ArtTop" class="fly" href="/script/Articles/TopArticles.aspx?ta_so=5">Top Articles</a></li>
		<li><a id="ctl00_TopNavBar_ArtBeginner" class="fly" href="/search.aspx?aidlst=152&amp;sa_us=True">Beginner Articles</a></li>
		<li id="ctl00_TopNavBar_VideosLink">
			<a id="ctl00_TopNavBar_ArtVideoArticles" class="fly" href="/script/Articles/VideoArticleList.aspx">Video Articles</a>
		</li>
		<li><a id="ctl00_TopNavBar_ArtBlogArticles" class="fly break" href="/script/Articles/BlogArticleList.aspx">Technical Blogs</a></li>
		<li><a id="ctl00_TopNavBar_ArtPostArticle" class="fly" href="/script/Articles/Submit.aspx">Submit an Article or Tip</a></li>
		<li><a id="ctl00_TopNavBar_ArtPostBlog" class="fly break" href="/script/Articles/BlogFeed.aspx">Post your Blog</a></li>
		<li><a id="ctl00_TopNavBar_ArtGuide" class="fly" href="/info/Submit.aspx">Posting/Update Guidelines</a></li>
		<li><a id="ctl00_TopNavBar_ArtCompetition" class="fly last" href="/script/Awards/CurrentCompetitions.aspx?cmpTpId=1">Article Competition</a></li>
	</ul>

</li>



<li><a id="ctl00_TopNavBar_Answers" href="/script/Answers/List.aspx?tab=active">Quick Answers</a>
	<ul class="openable">
		<li id="ctl00_TopNavBar_AQL"><a id="ctl00_TopNavBar_ArticleQuestion" class="fly highlight" href="#_comments">Ask a Question about this article</a></li>

		<li><a id="ctl00_TopNavBar_QAAsk" class="fly" href="/Questions/ask.aspx">Ask a Question</a></li>

		
		<li><a id="ctl00_TopNavBar_QAUnanswered" class="fly" href="/script/Answers/List.aspx?tab=unanswered">View Unanswered Questions</a></li>
		<li><a id="ctl00_TopNavBar_QALatest" class="fly" href="/script/Answers/List.aspx?tab=active">View All Questions...</a></li>
		
				<li><a id="ctl00_TopNavBar_QATR_ctl00_Tag" class="fly" href="/script/Answers/List.aspx?tab=active&amp;alltags=true&amp;tags=81" style="padding-left:30px">C# questions</a></li>
			
				<li><a id="ctl00_TopNavBar_QATR_ctl01_Tag" class="fly" href="/script/Answers/List.aspx?tab=active&amp;alltags=true&amp;tags=85" style="padding-left:30px">ASP.NET questions</a></li>
			
				<li><a id="ctl00_TopNavBar_QATR_ctl02_Tag" class="fly" href="/script/Answers/List.aspx?tab=active&amp;alltags=true&amp;tags=842" style="padding-left:30px">VB.NET questions</a></li>
			
				<li><a id="ctl00_TopNavBar_QATR_ctl03_Tag" class="fly" href="/script/Answers/List.aspx?tab=active&amp;alltags=true&amp;tags=78" style="padding-left:30px">C++ questions</a></li>
			
				<li><a id="ctl00_TopNavBar_QATR_ctl04_Tag" class="fly" href="/script/Answers/List.aspx?tab=active&amp;alltags=true&amp;tags=308" style="padding-left:30px">C#4.0 questions</a></li>
			
	</ul>

</li>



<li><a id="ctl00_TopNavBar_Forums" href="/script/Forums/List.aspx">Discussions</a>

	<ul class="openable">
		<li><a id="ctl00_TopNavBar_MessageBoardsAll" class="fly" href="/script/Forums/List.aspx">All Message Boards...</a></li>
		<li><a class="fly" style="padding-left:30px" href="/Forums/1580997/Application-Lifecycle.aspx">Application Lifecycle<span class="fly-menu">&gt;</span></a>
<ul class="openable"><li><a class="fly" href="/Forums/1533717/Running-a-Business.aspx">Running a Business</a></li>
<li><a class="fly" href="/Forums/1533716/Sales-Marketing.aspx">Sales / Marketing</a></li>
<li><a class="fly" href="/Forums/1651/Collaboration-Beta-Testing.aspx">Collaboration / Beta Testing</a></li>
<li><a class="fly" href="/Forums/3304/Work-Training-Issues.aspx">Work &amp; Training Issues</a></li>
</ul></li>
<li><a class="fly" style="padding-left:30px" href="/Forums/369270/Design-and-Architecture.aspx">Design and Architecture</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/12076/ASP-NET.aspx">ASP.NET</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1580226/JavaScript.aspx">JavaScript</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1647/C-Cplusplus-MFC.aspx">C / C++ / MFC<span class="fly-menu">&gt;</span></a>
<ul class="openable"><li><a class="fly" href="/Forums/4486/ATL-WTL-STL.aspx">ATL /  WTL / STL</a></li>
<li><a class="fly" href="/Forums/3785/Managed-Cplusplus-CLI.aspx">Managed C++/CLI</a></li>
</ul></li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1649/Csharp.aspx">C#</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1627782/Free-Tools.aspx">Free Tools</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1725/Database.aspx">Database</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/186301/Hardware-Devices.aspx">Hardware &amp; Devices<span class="fly-menu">&gt;</span></a>
<ul class="openable"><li><a class="fly" href="/Forums/1644/System-Admin.aspx">System Admin</a></li>
</ul></li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1606152/Hosting-and-Servers.aspx">Hosting and Servers</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1643/Java.aspx">Java</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1650/NET-Framework.aspx">.NET Framework</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/13695/Mobile.aspx">Mobile</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1653293/VS-11-NET-4-5.aspx">VS 11 &amp; .NET 4.5</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1540733/Sharepoint.aspx">Sharepoint</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1004257/Silverlight-WPF.aspx">Silverlight / WPF</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1646/Visual-Basic.aspx">Visual Basic</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1640/Web-Development.aspx">Web Development</a>
</li>
<li><a class="fly" style="padding-left:30px" href="/Forums/1645/Site-Bugs-Suggestions.aspx">Site Bugs / Suggestions</a>
</li>

		<li class="heading">Other Languages<span class="fly-menu">&gt;</span>
		<ul class="openable">
		<li><a class="fly" href="/Forums/1580229/Hindi.aspx">General Indian Topics</a></li>
		<li><a class="fly" href="/Forums/1580230/Chinese.aspx">General Chinese Topics</a></li>
		</ul>
		</li>
		
	</ul>

</li>

<li><a id="ctl00_TopNavBar_Zones" href="/Zones/index.aspx">Zones</a>

	<ul class="openable">
		<!--<li class="heading">Zones</li>-->
		<li><a href="/Zones/Commerce/" class="fly">The Commerce Zone</a></li><li><a href="/Zones/Mobile/" class="fly">The Mobile & App Zone</a></li><li><a href="/Zones/Cloud/" class="fly">The Cloud Zone</a></li><li><a href="/Zones/Hardware/" class="fly">The Hardware Zone</a></li><li><a href="/Zones/Parallelism/" class="fly">The Parallelism Zone</a></li><li><a href="/Zones/WPF-Silverlight/" class="fly">The WPF / Silverlight Zone</a></li><li><a href="/Zones/Flex-Flash/" class="fly">The Flex / Flash Zone</a></li><li><a href="/Zones/HTML-CSS/" class="fly">The HTML5 / CSS3 Zone</a></li><li><a href="/Zones/SharePoint/" class="fly">SharePoint Zone</a></li><li><a href="/Zones/SqlServer/" class="fly">The SQL Zone</a></li><li><a href="/Zones/WhitePapers/" class="fly break">WhitePapers / Webcasts</a></li>
		<li><a id="ctl00_TopNavBar_Solutions" class="fly last" href="/KB/solution-center/">Solutions Center</a></li>
	</ul>

</li>










<li><a id="ctl00_TopNavBar_Features" href="/Feature/">Features</a>

	<ul class="openable">
		<li><a id="ctl00_TopNavBar_WhosWho" class="fly" href="/script/Membership/Profiles.aspx">Who's Who</a></li>
		<li><a id="ctl00_TopNavBar_MVPs" class="fly" href="/script/Awards/MVPWinners.aspx">Most Valuable Professionals</a></li>
		<li><a id="ctl00_TopNavBar_Companies" class="fly break" href="/script/Membership/Profiles.aspx?mgtid=1&amp;mgm=True">Company Listings</a></li>
		<li><a id="ctl00_TopNavBar_Catalog" class="fly" href="/script/Catalog/List.aspx">Component & Service Catalog</a></li>
		<li><a id="ctl00_TopNavBar_Comps" class="fly" href="/script/Awards/CurrentCompetitions.aspx?cmpTpId=1&amp;awsac=true">Competitions</a></li>
		<li><a id="ctl00_TopNavBar_News" class="fly" href="/script/News/List.aspx">News</a></li>
		<li></li>
		<li><a id="ctl00_TopNavBar_Insider" class="fly" href="/Feature/Insider/">The Insider Newsletter</a></li>
		<li><a id="ctl00_TopNavBar_Newsletters" class="fly" href="/script/Mailouts/Archive.aspx?mtpid=1">Newsletter archive</a></li>
		<li><a id="ctl00_TopNavBar_PressRelease" class="fly" href="/script/PressReleases/Preview.aspx">Press Releases</a></li>
		<li><a id="ctl00_TopNavBar_Surveys" class="fly" href="/script/Surveys/List.aspx">Surveys</a></li>
		<li><a id="ctl00_TopNavBar_Stuff" class="fly last" href="/Info/Stuff.aspx">CodeProject Stuff</a></li>
		<li></li>
	</ul>

</li>


<li><a id="ctl00_TopNavBar_Help" href="/KB/FAQs/">Help!</a>

	<ul class="openable">
		<li><a id="ctl00_TopNavBar_HelpWhatIs" class="fly" href="/info/guide.aspx">What is 'The Code Project'?</a></li>
		<li><a id="ctl00_TopNavBar_HelpGeneral" class="fly" href="/KB/FAQs/">General FAQ</a></li>
		<li><a id="ctl00_TopNavBar_HelpPostQuestion" class="fly" href="/Questions/ask.aspx">Post a Question</a></li>
		<li><a id="ctl00_TopNavBar_HelpBugs" class="fly" href="/Forums/1645/Site-Bugs-Suggestions.aspx">Bugs and Suggestions</a></li>
		<li><a id="ctl00_TopNavBar_HelpSiteMap" class="fly" href="/script/Content/SiteMap.aspx">Site Map</a></li>
		<li><a id="ctl00_TopNavBar_HelpAdvertise" class="fly" href="http://lakequincy.com/">Advertise with us</a></li>
		<li><a id="ctl00_TopNavBar_HelpAboutUs" class="fly last" href="/info/about.aspx">About Us</a></li>
	</ul>

</li>


<li style="margin-left:10px">
<a id="ctl00_TopNavBar_Lounge" class="simple" href="/Lounge.aspx">The Lounge</a>

	<ul class="openable">
		<li><a id="ctl00_TopNavBar_InsiderLnk" class="fly" href="/Insider.aspx">The Insider News</a></li>
		<li><a id="ctl00_TopNavBar_LoungeLnk" class="fly" href="/Lounge.aspx">The Lounge  </a></li>
		<li><a id="ctl00_TopNavBar_CleverLnk" class="fly" href="/Feature/CleverCode.aspx">Clever Code</a></li>
		<li><a id="ctl00_TopNavBar_ShameLnk" class="fly" href="/Feature/HallOfShame.aspx">Hall of Shame</a></li>
		<li><a id="ctl00_TopNavBar_SoapBoxLnk" class="fly" href="/Forums/1536756/The-Soapbox.aspx">The Soapbox</a></li>
	</ul>

</li>

</ul>

</div>

		</td><td align="right">
			

<div class="search-bar">

<form method="get" action="/search.aspx" name="Search" class="tight">


<table border="0" cellspacing="0" cellpadding="0" class="search"><tr><td><input TabIndex="2" class="search " id="sb_tb" value="" name="q" /></td><td><input type="image" src="/images/search.gif" /></td></tr></table>

<div class="hover-container">
	<div id="SearchFilter" class="search-advanced popup small-text align-left">
	<b>Search within:<br /></b>
		
		<input type="radio" id="sb_kw" name="sbo" value="kw" checked="true"><label for="sb_kw">Articles</label><br>
<input type="radio" id="sb_qa" name="sbo" value="qa"><label for="sb_qa">Quick Answers</label><br>
<input type="radio" id="sb_fm" name="sbo" value="fm"><label for="sb_fm">Messages</label><br>
<input type="radio" id="sb_ctlk" name="sbo" value="ctlk"><label for="sb_ctlk">Product Catalog</label><br>


		
		
	</div>
</div>
</form>

</div>
		</td></tr></table>
		

		
		<div class="container-article hreview-aggregate"> 
		
			
			<div class="container-header">
				<div id="ctl00_Header" class="header">

					<a name="Main"></a>

					
					<a name="_articleTop" id="_articleTop"></a>
					

<div class="clearfix hover-container">

	
	<div class="float-right action-links"> 
		<span id="SBI"><img src="http://s.codeproject.com/images/share_drop24.png" id="ctl00_TitleArea_ActionLinks_AddTo_Img" width="37" height="24" alt="add" style="vertical-align:middle" />
</span>
<div id="ATD" class="list-socialbookmark"></div> 
 

<span class="tooltip">
	<a id="ctl00_TitleArea_ActionLinks_ArticleBmk_ImgBt" title="Bookmark" AlternateText="Bookmark" name="bm_7665_2" onclick="return bookmarkMe(7665,2,&#39;/script/Bookmarks/Ajax/Add.aspx?obid=7665&amp;obtid=2&amp;action=AddBookmark&amp;bio=true&#39;,true);" href="/script/Bookmarks/Add.aspx?obid=7665&amp;obtid=2&amp;action=AddBookmark&amp;bio=true" style="display:inline-block;height:24px;width:24px;vertical-align:middle;"><img title="Bookmark" src="http://s.codeproject.com/script/Bookmarks/Images/bookmark.png" alt="" style="border-width:0px;" /></a>


<span id="ctl00_TitleArea_ActionLinks_ArticleBmk_StatusMsg" class="tiny-text" style="display:none" name="bm_7665_2"></span>
 
	<div class="speech-bubble-container-up">
		<div class="speech-bubble-up">Add to your CodeProject bookmarks</div>
		<div class="speech-bubble-pointer-up">
			<div class="speech-bubble-pointer-up-inner"></div>
		</div>
	</div>
</span>


<a id="ctl00_TitleArea_ActionLinks_PrintLnk" class="tooltip" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?display=Print">
	<img src="http://s.codeproject.com/script/Content/Images/print.gif" 
		width="24px" height="24px" style="vertical-align:middle;border:0">
	<div class="speech-bubble-container-up">
		<div class="speech-bubble-up">Print Article</div>
		<div class="speech-bubble-pointer-up">
			<div class="speech-bubble-pointer-up-inner"></div>
		</div>
	</div>
</a>
	</div>

	<div class="container">
		
		<div class="breadcrumb float-left"><a href="/script/Content/SiteMap.aspx"><span class="sitemap-anchor" onmouseover="navBarMenu.ShowMap(this,'map');"><img width="16px" height="16px" src="/images/sitemap16.png" border="0" alt="Site map" style="vertical-align:middle" /><div id="map" class="tooltip-flyout"><img src="/images/animated.gif" style="margin:150px;width:100px;height:100px;border:0;" /></div></span></a> &#187; <a href="/Chapters/7/General-Reading.aspx">General Reading</a> &#187; <a href="/KB/system/">Hardware & System</a> &#187; <a href="/KB/system/#Windows+Services">Windows Services</a></div>
	</div>

	
	<div id="ctl00_TitleArea_InfoArea" class="float-right pad-top">
		

<div class="infobox">
	<table class="tight small-text" cellpadding="0" cellspacing="1">
	<tr><td>Licence&nbsp;</td><td></td></tr>
	
	<tr><td>First Posted&nbsp;</td><td nowrap="nowrap"><b>7 Jul 2004</b></td></tr>
	<tr><td>Views&nbsp;</td><td><b>64,146</b></td></tr>
		
	
	<tr><td>Bookmarked&nbsp;</td><td><b>33 times</b></td></tr>
	

	
	
	</table>
</div>	
	</div>

	
	<div class="item">
	<h1 id="ctl00_TitleArea_ArticleTitle" class="fn">Extend ServiceController class to change the StartupType of Windows Services</h1> 
	</div>

	
	<div class="author">
		By <b><a rel="author" href="/script/Membership/View.aspx?mid=466803">Mohamed Sharaf</a></b> | 
		7 Jul 2004 
		
		| <a id="ctl00_TitleArea_ArticleInfoLink" href="/script/Articles/Types.aspx?#Article">Article</a>

		
		
	</div>
	
	<div class="tags">
	<span id="ctl00_TitleArea_TagsList_TagWrp" class="tags">
	
	
	
	<span id="ctl00_TitleArea_TagsList_VisibleTags"><span class="t"><a rel="tag" href="/Tags/.NET1.0">.NET1.0</a></span><span class="t"><a rel="tag" href="/Tags/.NET1.1">.NET1.1</a></span><span class="t"><a rel="tag" href="/Tags/VS.NET2003">VS.NET2003</a></span><span class="t"><a rel="tag" href="/Tags/C%23">C#</a></span><span class="t"><a rel="tag" href="/Tags/Windows">Windows</a></span><span class="t"><a rel="tag" href="/Tags/Dev">Dev</a></span><span class="t"><a rel="tag" href="/Tags/Intermediate">Intermediate</a></span></span> 

	
	
</span>

	</div>

	
	<div class="abstract summary"><span id="ctl00_TitleArea_ArticleDescr">How to control the windows service&#39;s StartupType and extend the functionality of the ServiceController class</span></div>
</div>



					

				</div>

				<div id="ctl00_HeadSide" class="header-sidebar">
					<div class="align-left" style="height:24px">
						


&nbsp;










					</div>

					

<div class="bold pad-top">See Also</div>
<ul class="outdent small-text" style="margin-left:5px">
	<li><a id="ctl00_SeeAlso_LikeThis" href="/search.aspx?q=Extend+ServiceController+class++change++StartupType+of+Windows+Services">More like this</a></li>
	<li><a id="ctl00_SeeAlso_ByAuthor" href="/script/Articles/MemberArticles.aspx?amid=466803">More by this author</a></li>
</ul>

				</div>

			</div>
			

			
			<div id="ctl00_Nav" class="container-nav">
				<div id="ctl00_TabContainer" class="tabs-container clearfix">

					<div class="float-left">
						
						

<div class="tabs float-left"><table cellpadding="0" cellspacing="0"><tr>
	<td class="tab-selected">Article</td><td class="tab-unselected"><a href="/script/Articles/ViewDownloads.aspx?aid=7665">Browse Code</a></td><td class="tab-unselected"><a href="/script/Articles/Statistics.aspx?aid=7665">Stats</a></td><td class="tab-unselected"><a href="/script/Articles/ListVersions.aspx?aid=7665">Revisions</a></td><td class="tab-unselected"><a href="/script/Articles/ListAlternatives.aspx?aid=7665">Alternatives</a></td>
</tr></table></div>	


						
						<div class="float-left" style="margin-left:15px">
							<div id="ctl00_CurRat" class="tooltip anchorLink" style="cursor:pointer" onclick="scrollToAnchor(&#39;#_rating&#39;);" name="CurRat_7665">
								

<table cellpadding="0" cellspacing="0" class="small-text">
<tr>
	
	<td class="nowrap">

		<span id="ctl00_ArticleRating_VI">
		<div class="nowrap rating-stars" style="height:24px;width:120px;position:relative;">
	<div class="clipped align-left float-left" style="height:24px;width:107px;">
		<img src="http://s.codeproject.com/script/Ratings/Images/stars-fill.png" style="border-width:0px;" />
	</div><div class="clipped" style="height:24px;width:13px;position:relative;">
		<img src="http://s.codeproject.com/script/Ratings/Images/stars-empty.png" style="border-width:0px;position:absolute;top:0;right:0;" />
	</div>
</div>
		</span>

		
	</td>
	
	<td id="ctl00_ArticleRating_VR" class="nowrap">
		&nbsp;
		<span id="ctl00_ArticleRating_VotesR">&nbsp;<span class="rating">4.46</span> (<span class="count">19 votes</span>)</span>
		
	</td>

</tr>

</table>

								<div id="ctl00_RB" class="speech-bubble-container-up">
									<div class="speech-bubble-up" style="width:150px !important">
										            
<div>
<table class="feature" width="100%" height="50px" title="Voting Distribution. Recent data only" cellpadding="0" cellspacing="0"><tr><td class="chart-column rating-ignore-vote" title="Outside deviation limits - not included in score."><img src="/script/Ratings/Images/pollcol.gif" width="20pxpx" height="3px" border="0px" alt="1 vote, 5.3%" title="1 vote, 5.3%" /><br /><span title="1 vote">1</span></td>
<td class="chart-column rating-ignore-vote" title="Outside deviation limits - not included in score."><img src="http://s.codeproject.com/Images/t.gif" width="20pxpx" height="1px" border="0px" alt="" title="" /><br /><span title="0 votes">2</span></td>
<td class="chart-column"><img src="/script/Ratings/Images/pollcol.gif" width="20pxpx" height="3px" border="0px" alt="1 vote, 5.3%" title="1 vote, 5.3%" /><br /><span title="1 vote">3</span></td>
<td class="chart-column"><img src="/script/Ratings/Images/pollcol.gif" width="20pxpx" height="15px" border="0px" alt="4 votes, 21.1%" title="4 votes, 21.1%" /><br /><span title="4 votes">4</span></td>
<td class="chart-column"><img src="/script/Ratings/Images/pollcol.gif" width="20pxpx" height="50px" border="0px" alt="13 votes, 68.4%" title="13 votes, 68.4%" /><br /><span title="13 votes">5</span></td>
</tr></table><div class="small-text align-center">4.46/5 - 19 votes</div><div class="small-text align-center subdue">1 removed</div><div class="small-text align-center subdue">μ 4.03, σ<sub>a</sub> 1.79 [<a href="/KB/FAQs/RatingReputationFAQ.aspx#noisefilter">?</a>]</div>
</div>
									</div>
									<div class="speech-bubble-pointer-up">
										<div class="speech-bubble-pointer-up-inner"></div>
									</div>
								</div>
							</div>
						</div>

						<div class="float-left">
							&nbsp; 
							<a id="discussAnch" href="#_comments" class="tooltip anchorLink">
							<img src="http://s.codeproject.com/script/Content/Images/discuss.gif" 
								width="24px" height="24px" alt="Discuss" style="vertical-align:middle;border:0" />
								<div class="speech-bubble-container-up">
									<div class="speech-bubble-up">Discuss this article</div>
									<div class="speech-bubble-pointer-up">
										<div class="speech-bubble-pointer-up-inner"></div>
									</div>
								</div>
							</a>
							<span id="ctl00_CmtCnt" class="subdue small-text align-middle" style="margin-left:-4px">16</span>

							&nbsp; <span id="ctl00_ReportItem_StatusMsg" class="tiny-text" style="display:none"></span>


<span id="ctl00_ReportItem_CurRpt" class="tooltip">	
		<img id="ctl00_ReportItem_MenuImage" alt="report" src="http://s.codeproject.com/script/Content/Images/report.gif" style="border-width:0px;vertical-align:middle" />
		
		<div class="tooltip-flyout" style="width:220px !important" onmouseover="CheckForUndo(this);">
			<div id="ctl00_ReportItem_CommentDiv" class="small-text">
			<b>Comments?</b><br />
				<input name="ctl00$ReportItem$Comments" type="text" id="ctl00_ReportItem_Comments" class="report-comment" />
			</div>
			 
			
					<div id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_Header" class="report-header">Report</div>
					
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_ReportingTypes_ctl00_Link" name="rpt_7665_2_1" onclick="return ReportMe(7665,2,1,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=1&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=1">Unclear or Incomplete</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_ReportingTypes_ctl01_Link" name="rpt_7665_2_10" onclick="return ReportMe(7665,2,10,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=10&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=10">Extremely poor quality</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_ReportingTypes_ctl02_Link" name="rpt_7665_2_4" onclick="return ReportMe(7665,2,4,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=4&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=4">Off-topic</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_ReportingTypes_ctl03_Link" name="rpt_7665_2_5" onclick="return ReportMe(7665,2,5,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=5&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=5">Spam/abusive</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_ReportingTypes_ctl04_Link" name="rpt_7665_2_11" onclick="return ReportMe(7665,2,11,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=11&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=11">Plagiarized</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl00_ReportingTypes_ctl05_Link" name="rpt_7665_2_12" onclick="return ReportMe(7665,2,12,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=12&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=12">Inaccurate / Misleading</a>
							</div>
						 
			   
					<div id="ctl00_ReportItem_ReportingTypeHeaders_ctl01_Header" class="report-header">Needs help</div>
					
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl01_ReportingTypes_ctl00_Link" name="rpt_7665_2_14" onclick="return ReportMe(7665,2,14,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=14&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=14">Format / layout issues</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl01_ReportingTypes_ctl01_Link" name="rpt_7665_2_15" onclick="return ReportMe(7665,2,15,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=15&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=15">Wrong section / tags</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl01_ReportingTypes_ctl02_Link" name="rpt_7665_2_16" onclick="return ReportMe(7665,2,16,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=16&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=16">Wrong type (tip, blog, article)</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl01_ReportingTypes_ctl03_Link" name="rpt_7665_2_17" onclick="return ReportMe(7665,2,17,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=17&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=17">Missing images/downloads</a>
							</div>
						 
							<div class="report-prompt nowrap">
								
								<a id="ctl00_ReportItem_ReportingTypeHeaders_ctl01_ReportingTypes_ctl04_Link" name="rpt_7665_2_18" onclick="return ReportMe(7665,2,18,&#39;/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=18&amp;ajax=True&#39;,false,&#39;ctl00_ReportItem_Comments&#39;);" href="/script/Content/Report.aspx?obtid=2&amp;obid=7665&amp;obstid=1&amp;ovid=1&amp;rid=18">Images/downloads are offsite</a>
							</div>
						 
			   

			<div class="Undo"></div>
		</div>
	</span>



							   
						</div>

					</div>

				</div>

				
			</div>
			

			
			<div class="container-text">

				<div id="AT" class="text">
					
					
					
					

						
							
			
					<div id="ctl00_confirmError" class="callout small-text" style="padding:10px;margin:20px;"><img style="float:left;margin-right:10px" 
					src="/images/warning_32.png" width="32px" height="32px" /><b>Is your email address OK?</b>
					You are signed up for our newsletters but your email address is either unconfirmed, or has not 
					been reconfirmed in a long time. Please click 
					<a id="ctl00_RequestConfirmLink2" href="/script/Membership/SendConfirmRequest.aspx?rp=%2fArticles%2f7665%2fExtend-ServiceController-class-to-change-the-Start">here</a> to have a 
					confirmation email sent so we can confirm your email address and start sending you newsletters 
					again. Alternatively, you can 
					<a id="ctl00_SubscribeLink2" href="/script/Membership/Subscribe.aspx?rp=%2fArticles%2f7665%2fExtend-ServiceController-class-to-change-the-Start">update your subscriptions</a>.</div><form name="aspnetForm" method="post" action="/Articles/7665/Extend-ServiceController-class-to-change-the-Start" id="aspnetForm" style="margin:0;padding:0">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjExOTQzNjk4Mw9kFgJmD2QWAgIHD2QWCAIRD2QWAgIBD2QWBmYPDxYCHgtOYXZpZ2F0ZVVybAUxL3NjcmlwdC9BcnRpY2xlcy9BZG1pbi9FZGl0b3JDaG9pY2UuYXNweD9haWQ9NzY2NWRkAgIPDxYCHwAFNy9zY3JpcHQvQXdhcmRzL0FkbWluL0F3YXJkT2JqZWN0LmFzcHg/b2JpZD03NjY1Jm9idGlkPTJkZAIKDw8WAh8ABS4vc2NyaXB0L0FydGljbGVzL0FkbWluL1F1ZXVlRWRpdC5hc3B4P2FpZD03NjY1ZGQCEw9kFgICAQ9kFgICAg8WAh4JaW5uZXJodG1sBQIxNmQCFQ9kFgICCw9kFggCAQ8WAh4HVmlzaWJsZWcWBAIBDw8WAh8ABXUvc2NyaXB0L01lbWJlcnNoaXAvU2VuZENvbmZpcm1SZXF1ZXN0LmFzcHg/cnA9JTJmQXJ0aWNsZXMlMmY3NjY1JTJmRXh0ZW5kLVNlcnZpY2VDb250cm9sbGVyLWNsYXNzLXRvLWNoYW5nZS10aGUtU3RhcnRkZAIDDw8WAh8ABWwvc2NyaXB0L01lbWJlcnNoaXAvU3Vic2NyaWJlLmFzcHg/cnA9JTJmQXJ0aWNsZXMlMmY3NjY1JTJmRXh0ZW5kLVNlcnZpY2VDb250cm9sbGVyLWNsYXNzLXRvLWNoYW5nZS10aGUtU3RhcnRkZAICDxYCHgZhY3Rpb24FQS9BcnRpY2xlcy83NjY1L0V4dGVuZC1TZXJ2aWNlQ29udHJvbGxlci1jbGFzcy10by1jaGFuZ2UtdGhlLVN0YXJ0FgoCAQ8PFgQfAAU1L3NjcmlwdC9BcnRpY2xlcy9TdWJtaXNzaW9uV2l6YXJkLmFzcHg/YXQ9MSZhcGlkPTc2NjUfAmdkZAIDD2QWAgIBDxYCHwJoZAIFD2QWAgICD2QWAgIBDxBkZBYAZAILDxYCHgtfIUl0ZW1Db3VudAIBZAIND2QWAgIBDxYCHgRUZXh0BXo8YSBjbGFzcz0iYW5jaG9yTGluayIgaHJlZj0iL0FydGljbGVzLzc2NjUvRXh0ZW5kLVNlcnZpY2VDb250cm9sbGVyLWNsYXNzLXRvLWNoYW5nZS10aGUtU3RhcnQjX2FydGljbGVUb3AiPkFydGljbGUgVG9wPC9hPmQCCg8PFgQfBQUJUGVybWFsaW5rHwAFQS9BcnRpY2xlcy83NjY1L0V4dGVuZC1TZXJ2aWNlQ29udHJvbGxlci1jbGFzcy10by1jaGFuZ2UtdGhlLVN0YXJ0ZGQCGQ8WAh8FBSBDb3B5cmlnaHQgMjAwNCBieSBNb2hhbWVkIFNoYXJhZmQCFw9kFgICBQ8PFgIfAmhkZGRi9PKeO2SBUTNaprHZHXQBfwz12w==" />
</div>

<div>

	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCQKo2qOCBgKi6fqQCgLAlMXDBwLBlMXDBwLClMXDBwLDlMXDBwLElMXDBwLP+++tCwK5upDkC+ZsmWOvqFS5Gp0tnJbHcwrvKP/E" />
</div>

						<a id="ctl00_AddAlternative" title="Write a related article about upgrades or translate this into a different language." class="button add-alternative float-right" href="/script/Articles/SubmissionWizard.aspx?at=1&amp;apid=7665">Add your own<br />alternative version</a>

						<!-- Article Text Start -->
						<div id="contentdiv">
						



<UL class=download>
<LI><A href="/KB/system/ExtendServiceController/Article_demo.zip">Download demo project - 7 Kb </A>
<LI><A href="/KB/system/ExtendServiceController/Article_src.zip">Download source - 13 Kb</A> </LI></UL>
<P><IMG height=405 src="/KB/system/ExtendServiceController/sample.GIF" width=519 border=0></P>
<H2>Introduction</H2>
<P>In this article we will extend the functionality of the <CODE>ServiceController</CODE> class to control any windows service’s StartupType. In addition to obtaining more information about the service such as service Description. I'll use the WMI classes in Net Framework included in <CODE>System.Management</CODE> namespace. 
<H2>Background </H2>
<P>The Net Framework gave us a flexible advanced framework to do a lot of tasks that we needed to implement. One of these features included in the <CODE>System.ServiceProcess</CODE> namespace. This namespace contains classes that allow us to implement, control and install windows services. For more information refer to <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemserviceprocess.asp?frame=true">System.ServiceProcess Namespace</A> in MSDN</P>
<TABLE width="100%" border=1>
<TBODY>
<TR width="100%">
<TD width="100%">Note: Windows Service is a long running executable that run without user interface (for example the application that receive string messages from other machine and display it as message box to the user called Messenger Service) </TD></TR></TBODY></TABLE>
<P>One of these classes is the <CODE>ServiceController</CODE> class which enables us to query windows service for its state and control it. You can use code like the following to connect to the <B>telnet service</B>, query for its status and if it's stopped, run it. </P><PRE lang=cs>ServiceController sc = <span class="code-keyword">new</span> ServiceController(<span class="code-string">"</span><span class="code-string">Telnet"</span>);
<span class="code-keyword">if</span> (sc.Status.Equals(ServiceControllerStatus.Stopped))
{
sc.Start();
}
<span class="code-keyword">else</span>
{
sc.Stop();
}
</PRE>
<TABLE width="100%" border=1>
<TBODY>
<TR width="100%">
<TD width="100%">Note: To run the previous code, you should add a reference to <B>System.ServiceProcess.dll</B> and add the using keyword in the file that contains this snippet. </TD></TR></TBODY></TABLE><BR>You can also search for the all Win32 services installed in the machine by using the <CODE>ManagementObjectSearcher</CODE> as following <PRE lang=cs>ManagementObjectSearcher objSearcher =
  <span class="code-keyword">new</span> ManagementObjectSearcher(<span class="code-string">"</span><span class="code-string">Select * from Win32_Service"</span>);
<span class="code-keyword">foreach</span>(ManagementObject service <span class="code-keyword">in</span> objSearcher.Get())
{
<span class="code-keyword">this</span>.listBox1.Items.Add(service[<span class="code-string">"</span><span class="code-string">name"</span>]);
}</PRE>
<P>But I noticed that the <CODE>ServiceController</CODE> class missed two things:</P>
<UL>
<LI>Get the description of the service 
<LI>Get or set the StartupType of the service (which is very important if you planning to use service that's may be disabled)</LI></UL>I faced this problem with the <B>Messenger service</B> which is disabled by default in <B>Windows Server 2003</B> and <B>windows XP SP2</B>. And I found the solution for this situation in the <B>WMI</B>. 
<H2><A name=WMIArch></A>Windows Management Instrumentation (WMI)</H2>WMI is the Microsoft implementation of the <B>Web Based Enterprise Management (WBEM) </B>which is an industry initiative to develop a standard technology for accessing management information in an enterprise environment. For more information see <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_start_page.asp?frame=true">Windows Management Instrumentation</A> in the MSDN.<BR><BR>.NET framework implements these components in the <CODE>System.Management</CODE> namespace (see <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemManagement.asp?frame=true">System.Management namespace</A> in MSDN). 
<P></P>
<H2>WMI architecture</H2>
<P>We can think of WMI architecture as the Hardware drivers. In WMI there are mainly three components</P>
<TABLE width="40%" border=1>
<TBODY>
<TR>
<TD><B>Managed Objects</B></TD>
<TD>Like the Hardware device (i.e. sound card) </TD></TR>
<TR>
<TD><B>Providers</B></TD>
<TD>Like the device driver that shipped with the hardware device</TD></TR>
<TR>
<TD><B>WMI infrastructure</B></TD>
<TD>Windows service that mange the interaction between Managed Objects, Providers and Applications.</TD></TR>
<TR>
<TD colSpan=2>And there’s also the WMI management application which act as consumer to the providers (like what we will do now) </TD></TR></TBODY></TABLE><BR><BR>And the WMI service has a lot of Managed Objects and Providers shipped with it and one of these Managed Objects is the <CODE>Win32_Service</CODE> Managed Object which gives you the ability to monitor and control any <B>Win32 Service</B>. <BR><BR>
<TABLE width="100%" border=1>
<TBODY>
<TR width="100%">
<TD width="100%">Note: Please don’t mix with the WMI Managed Object and the Managed code. Managed Objects means the objects that con be managed by the WMI service </TD></TR></TBODY></TABLE>
<H2>Using the code</H2>
<P>What we want to do is to merge the features of the <CODE>serviceController</CODE> class with the <CODE>System.Management</CODE> namespace to produce <CODE>ServiceControllerEx</CODE> class which will take all the properties and methods of the <CODE>ServiceController</CODE> class beside two properties 
<UL>
<LI><CODE>Description</CODE> {get} 
<LI><CODE>StartupType</CODE> {get/set} </LI></UL>
<P>The first step is to add references to the <CODE>System.ServiceProcess</CODE> and <CODE>System.Management</CODE> namespaces then use the appropriate <CODE>using</CODE> statement.<BR><PRE lang=cs><span class="code-keyword">using</span> System;
<span class="code-keyword">using</span> System.ServiceProcess;
<span class="code-keyword">using</span> System.Management;
</PRE>
<H2>Inheritance and Constructors</H2>
<P>Inherit the <CODE>ServiceControllerEx</CODE> class from the Microsoft's <CODE>ServiceController</CODE> class <BR></P><PRE lang=cs><span class="code-keyword">public</span> <span class="code-keyword">class</span> ServiceControllerEx:ServiceController</PRE>And because the inheritance doesn't inherit the class's constructors, we should do it ourselves <BR><PRE lang=cs><span class="code-keyword">public</span> ServiceControllerEx():<span class="code-keyword">base</span>()
{ }
<span class="code-keyword">public</span> ServiceControllerEx(<span class="code-keyword">string</span> name):<span class="code-keyword">base</span>(name)
{ }
<span class="code-keyword">public</span> ServiceControllerEx(<span class="code-keyword">string</span> name,<span class="code-keyword">string</span> machineName):<span class="code-keyword">base</span>(name,machineName)
{ }
</PRE>In the previous code we just initiate the base class's constructors and we didn't add any custom implementation.<BR>
<H2>Description property</H2>Now come to the important part. Let's add the description property (note that it's Read only)<BR><PRE lang=cs><span class="code-keyword">public</span> <span class="code-keyword">string</span> Description
{
<span class="code-keyword">get</span>
{
<span class="code-comment">//</span><span class="code-comment">construct the management path
</span><span class="code-keyword">string</span> path=<span class="code-string">"</span><span class="code-string">Win32_Service.Name='"</span>+this.ServiceName+<span class="code-string">"</span><span class="code-string">'"</span>;
ManagementPath p=new ManagementPath(path);
<span class="code-comment">//</span><span class="code-comment">construct the management object
</span>ManagementObject ManagementObj=new ManagementObject(p);
<span class="code-keyword">if</span>(ManagementObj[<span class="code-string">"</span><span class="code-string">Description"</span>]!=null)
{
<span class="code-keyword">return</span> ManagementObj[<span class="code-string">"</span><span class="code-string">Description"</span>].ToString();
}
<span class="code-keyword">else</span>
{
<span class="code-keyword">return</span> <span class="code-keyword">null</span>;
}
}
}
</PRE>We used the <CODE>ManagementObject</CODE> class which represents a WMI Management Object (see <A href="#WMIArch">WMI architecture</A>). But to use it we should pass the path of the object to the constructor. The path of service like Messenger service should be like this <CODE>Win32_Service.Name='Messenger'. </CODE>This path says that we need a <B>Win32_Service</B> where its name is <B>Messenger</B><BR><BR>Because the <CODE>ManagementObject</CODE> class is not specific to the Windows services (we can use it to monitor the computer system hardware or even running processes) So there isn't a predefined properties regarding the Windows services but we use properties in the format of <CODE>ManagementObject["property name"]</CODE> So to get the Description of the service use the line <BR><PRE lang=cs><span class="code-keyword">return</span> ManagementObj[<span class="code-string">"</span><span class="code-string">Description"</span>].ToString();</PRE><BR>We used <CODE>ToString()</CODE> as this property returns object data Type. (For more information about the Win32_Service class and its properties and method please refer to <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_service.asp?frame=true">WMI documentation</A>)<BR>
<H2>Implementing StartupType property (get accessor)</H2><PRE lang=cs><span class="code-keyword">public</span> <span class="code-keyword">string</span> StartupType
{
<span class="code-keyword">get</span>
{
<span class="code-keyword">if</span>(<span class="code-keyword">this</span>.ServiceName != <span class="code-keyword">null</span>)
{
 <span class="code-comment">//</span><span class="code-comment">construct the management path
</span> <span class="code-keyword">string</span> path=<span class="code-string">"</span><span class="code-string">Win32_Service.Name='"</span>+this.ServiceName+<span class="code-string">"</span><span class="code-string">'"</span>;
 ManagementPath p=new ManagementPath(path);
 <span class="code-comment">//</span><span class="code-comment">construct the management object
</span> ManagementObject ManagementObj=new ManagementObject(p);
 <span class="code-keyword">return</span> ManagementObj[<span class="code-string">"</span><span class="code-string">StartMode"</span>].ToString();
}
<span class="code-keyword">else</span>
{
<span class="code-keyword">return</span> <span class="code-keyword">null</span>;
}
}
</PRE>In this peace of code we can use the same concept of the properties of the <CODE>Win32_Service</CODE> class. <BR>
<H2>StartupType property (set accessor)</H2><BR>For the set accessor the situation is different now because we will not query the management Object but we will change its state. See the following<BR><PRE lang=cs><span class="code-keyword">set</span>
{
<span class="code-keyword">if</span>(value!=<span class="code-string">"</span><span class="code-string">Automatic"</span> &amp;&amp; value!=<span class="code-string">"</span><span class="code-string">Manual"</span> &amp;&amp; value!=<span class="code-string">"</span><span class="code-string">Disabled"</span>)
<span class="code-keyword">throw</span> <span class="code-keyword">new</span> Exception(<span class="code-string">"</span><span class="code-string">The valid values are Automatic, Manual or Disabled"</span>);

<span class="code-keyword">if</span>(<span class="code-keyword">this</span>.ServiceName!=null)
{
<span class="code-comment">//</span><span class="code-comment">construct the management path
</span><span class="code-keyword">string</span> path=<span class="code-string">"</span><span class="code-string">Win32_Service.Name='"</span>+this.ServiceName+<span class="code-string">"</span><span class="code-string">'"</span>;
ManagementPath p=new ManagementPath(path);
<span class="code-comment">//</span><span class="code-comment">construct the management object
</span>ManagementObject ManagementObj=new ManagementObject(p);
<span class="code-comment">//</span><span class="code-comment">we will use the invokeMethod method of the ManagementObject class
</span><span class="code-keyword">object</span>[] parameters=new <span class="code-keyword">object</span>[<span class="code-digit">1</span>];
parameters[<span class="code-digit">0</span>]=value;
ManagementObj.InvokeMethod(<span class="code-string">"</span><span class="code-string">ChangeStartMode"</span>,parameters); 
}
}</PRE>To change the <CODE>StartupType</CODE> of the <CODE>Win32_Service</CODE> WMI class (or managed object) we will use the <CODE>changeStartupMode</CODE> of the <CODE>win32_Service</CODE> WMI object. To accomplish this we are using the <CODE>System.Management.ManagementObject</CODE> class and as we agreed we will not find a method called <CODE>ChangeStartupMode</CODE> but instead we will use the generic method called <CODE>InvokeMethod</CODE> which takes the method name of the WMI object (<CODE>ChangeStartupMode</CODE>) and any parameters that will be passed.<BR><PRE lang=cs><span class="code-keyword">object</span>[] parameters=new <span class="code-keyword">object</span>[<span class="code-digit">1</span>];
parameters[<span class="code-digit">0</span>]=value;
ManagementObj.InvokeMethod(<span class="code-string">"</span><span class="code-string">ChangeStartMode"</span>,parameters); </PRE>
<P>That's all. In few simple steps we managed to extend the functionality of the <CODE>ServiceController</CODE> class to be more useful for us. I attached the source code and executable which contains the new class and a sample windows application as a client. Please send me your feedback or enhancements.</P>
<H2>Points of Interest</H2>
<UL>
<LI>I've checked in <B>Framework v2.0</B> (Shipped with Visual Studio 2005 beta1) and I didn't find any changes in the behavior of the <CODE>ServiceController</CODE> class. 
<LI>The <CODE>StartupType</CODE> property takes the strings Automatic, Manual or Disabled. And return back Auto, Manual or Disabled so keep in mind to fine tune the property to unify the input and output. 
<LI>The testing application uses the <CODE>ServiceController</CODE> class to get the list of all services and add it to listBox then uses the modified <CODE>ServiceConrollerEx</CODE> to get and set the service's properties. </LI></UL>


						</div>
						<!-- Article Text End -->

						
						
						<h2>License</h2>
						<div id="LicenseTerms"><p>This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.</p><p>A list of licenses authors might use can be found <a href="/info/Licenses.aspx">here</a></p></div>
						

						
						<h2 id="ctl00_AboutHeading">About the Author</h2>

						<div class="float-right">
						<div class="lqm_ad" lqm_publisher="lqm.codeproject.site"  lqm_zone="ros" lqm_format="300x250" lqm_loadOnView='true'  lqm_tags='.NET1.0, .NET1.1, VS.NET2003, C#, Windows, Dev, Intermediate,rating4'></div>
						</div>

						
						
<table cellpadding="0" cellspacing="5" border="0">
<tr valign="top">
<td id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberPhotoTable" valign="top" style="width:155px;">
	<b><a id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberProfileLink" href="/Members/Mohamed-Sharaf">Mohamed Sharaf</a></b><br /><br />
	<center><img id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberPhoto" src="/script/Membership/ProfileImages/{C46B0DFE-7CA1-47B3-8960-B2B29AF21ADD}.jpg" style="border-width:0px;" /></center>

	<div class="small-text">
		<span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberJobTitle">Web Developer</span><br />
		<span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberCompany"></span><br />
		<span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberLocation"><img src="/script/Geo/Images/IE.gif" alt="Ireland" width="16px" height="11px" /> Ireland</span><br />
		<br />
		<span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberType">Member</span><br />
		
		<br />

		
	</div>
</td>

<td>
	Expert in Microsoft technologies.<br />
MCP+Site Building, MCSD, MCAD, and MCSD.NET (Early achiever)<br />
Worked as Web developer, Trainer and software developer<br />
Currently working as Developer support engineer.<br />
You can contact me also through my blog <a href="http://blogs.msdn.com/mohamed_sharafs_blog/" >http://blogs.msdn.com/mohamed_sharafs_blog/ </a><br />	
</td>
</tr>
</table><br />
						
						

						<div class="clearfix"></div>

						
						<div id="ctl00_RateArticleRow" class="clearfix voting-bar">
						<div class="float-left" style="padding-top:8px"><a class="anchorLink" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start#_articleTop">Article Top</a></div>
						<div class="float-right"><a id="_rating" name="_rating">&nbsp;</a></div> 
						<div class="float-right align-right">
							<div id="ctl00_RateArticle_RateItemWrapper" class="container-rating small-text" name="RateItem_7665">

	<table width="100%" cellpadding="0" cellspacing="0" class="small-text">
	<tr>
		<td id="ctl00_RateArticle_VoteResultDiv" nowrap="nowrap" align="right">
			<span class="voteRes"></span>
			<img class="loaderImg" width="16px" alt="loading..." height="16px" 
				src="/Images/animated_loading_blue.gif" style="display:none;" /> 
		</td>

	
		<td class="voteTbl" style="white-space:nowrap" align="right">
			<table class="small-text">
			<tr>
				
				<td id="ctl00_RateArticle_RateText" class="rating-prompt">
					Rate this:
				</td>

				<td id="ctl00_RateArticle_StartForm" align="right" nowrap="nowrap">
					<i>&nbsp;&nbsp;Poor</i>
				</td>

				<td id="ctl00_RateArticle_VoteFormDiv" class="nowrap">
					

					<span id="ctl00_RateArticle_RB" class="tooltip ajaxHist radio voting">
						<span id="ctl00_RateArticle_VoteRBL"><input id="ctl00_RateArticle_VoteRBL_0" type="radio" name="ctl00$RateArticle$VoteRBL" value="1" onclick="ChkRtctl00_RateArticle(1, 7665);
$(&#39;#ctl00_RateArticle_RCD&#39;).show();
;" /><input id="ctl00_RateArticle_VoteRBL_1" type="radio" name="ctl00$RateArticle$VoteRBL" value="2" onclick="ChkRtctl00_RateArticle(2, 7665);
$(&#39;#ctl00_RateArticle_RCD&#39;).show();
;" /><input id="ctl00_RateArticle_VoteRBL_2" type="radio" name="ctl00$RateArticle$VoteRBL" value="3" onclick="ChkRtctl00_RateArticle(3, 7665);
$(&#39;#ctl00_RateArticle_RCD&#39;).show();
;" /><input id="ctl00_RateArticle_VoteRBL_3" type="radio" name="ctl00$RateArticle$VoteRBL" value="4" onclick="ChkRtctl00_RateArticle(4, 7665);
$(&#39;#ctl00_RateArticle_RCD&#39;).show();
;" /><input id="ctl00_RateArticle_VoteRBL_4" type="radio" name="ctl00$RateArticle$VoteRBL" value="5" onclick="ChkRtctl00_RateArticle(5, 7665);
$(&#39;#ctl00_RateArticle_RCD&#39;).show();
;" /></span> 

						
					</span>

				</td>

				<td id="ctl00_RateArticle_EndForm" align="left">
					<i>Excellent</i>
				</td>

				<td>	
					<input type="submit" name="ctl00$RateArticle$SubmitRateBtn" value="Vote" onclick="return PostBack_ctl00_RateArticle_RateItemWrapper();" id="ctl00_RateArticle_SubmitRateBtn" class="button" />
				</td>
			</tr>
			</table>
			<span id="ctl00_RateArticle_ErrorMessage" class="error"></span>
		</td>
	</tr>
	</table>
	<div class="hover-container">
		<div id="ctl00_RateArticle_RCD" class="rating-comment align-left float-right">
			Add a reason or comment to your vote: <a href="#" id="clear-rate_ctl00_RateArticle_RCD" 
				title="close">x</a><br />
			<textarea class="RateComment" rows="5" cols="60" style="width:98%;"></textarea>
			<span id="ctl00_RateArticle_CommentReq" class="subdue">Votes of 3 or less require a comment</span>
		</div>
	</div>
</div>
						</div>
						</div>
						

					</form>

					
					<div style="margin:auto;width:728px;height:90px;margin-top:10px">		  
						<div class="lqm_ad" lqm_publisher="lqm.codeproject.site"  lqm_zone="bottom" lqm_format="728x90" lqm_loadOnView='true'  lqm_tags='.NET1.0, .NET1.1, VS.NET2003, C#, Windows, Dev, Intermediate,pos_bottom'></div>
					</div>
					

					
					
					<h2>Comments and Discussions</h2>
					<a name="_comments" id="_comments">&nbsp;</a><div id="_MessageBoardctl00_MessageBoard" onclick="return SwitchMessage(event, null)">
	<table id="ForumTable" class="box forum" cellpadding="0" cellspacing="0">
		<tr>
			<td><table width="100%" border="0" cellpadding="3px" cellspacing="0">
				<tr class="forum-header1">
					<td colspan="2" style="white-space:nowrap;"><div class="container">
						<div class="button-newmsg float-left" onclick="FireNew(this)">
							<img src="http://s.codeproject.com/script/Forums/Images/forum_newmsg.gif" alt="new" width="16px" height="16px" border="0" align="top" /> <a href="/script/Forums/Edit.aspx?fid=73954&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start" name="Frm_HoverNL" title="Add a Add a Comment or Question" target="_top"><b>Add a Comment or Question</b></a>
						</div>&nbsp;<div class="float-right">
							<form action="/Search.aspx?fid=0" method="get" class="tight">
								<input type="hidden" name="fid" value="73954" /><b>Search this forum </b><input type="text" class="Frm_Input" name="qf" style="width:200px;" />&nbsp;<input type="submit" value="Go" class="button" />
							</form>
						</div>
					</div></td><tr class="forum-header2">
						<td style="white-space:nowrap;">&nbsp;<a href="/KB/FAQs/MessageBoardsFAQ.aspx"><img src="http://s.codeproject.com/script/Forums/Images/msg_question.gif" title="FAQ" alt="FAQ" style="border-width:0;width:16px;height:16px;vertical-align:middle;" /></a></td><td style="width:100%;"><div style="text-align:right;">
							<form action="/script/Forums/SetOptions.aspx?floc=%2fArticles%2f7665%2fExtend-ServiceController-class-to-change-the-Start&amp;fid=73954" method="get" style="margin:0;padding:0;">
								<input type="hidden" name="fid" value="73954" /><input type="hidden" name="currentQS" value="?floc=%2fArticles%2f7665%2fExtend-ServiceController-class-to-change-the-Start&amp;fid=73954" /><input type="hidden" name="floc" value="/Articles/7665/Extend-ServiceController-class-to-change-the-Start" /><input type="checkbox" name="prof" id="prof" style="vertical-align:middle;" /><label for="prof">Profile popups</label>&nbsp;&nbsp;&nbsp;&nbsp;Noise<select size="1" class="Frm_DropDown" name="noise">
									<option value="1">Very High</option><option value="2">High</option><option selected value="3">Medium</option><option value="4">Low</option><option value="5">Very Low</option>
								</select>&nbsp;&nbsp;Layout<select size="1" class="Frm_DropDown" name="view">
									<option selected value="Quick">Normal</option><option value="Topic">Expand Posts only</option><option value="Expanded">Expand Posts & Replies</option><option value="Thread">Thread View</option><option value="Normal">No Javascript</option><option value="Preview">No JS + Preview</option>
								</select>&nbsp;&nbsp;Per page<select size="1" class="Frm_DropDown" name="mpp">
									<option value="10">10</option><option selected value="25">25</option><option value="50">50</option>
								</select>&nbsp;&nbsp;&nbsp;<input type="submit" value="Update" name="SetOpt" class="button" />
							</form>
						</div></td>
					</tr>
				</tr>
			</table></td><tr>
				<td><a name="xx0xx"></a><table border="0" cellpadding="2px" cellspacing="0" width="100%">
					<tr class="forum-navbar">
						<td>&nbsp;</td><td style="text-align:right;width:50%;"> <a href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954">Refresh</a></td><td class="nav-link" style="text-align:right;white-space:nowrap;"><span class="subdue">First</span> <span class="subdue">Prev</span> <span class="subdue">Next</span></td>
					</tr>
				</table></td>
			</tr><tr>
				<td><table border="0" cellpadding="0" cellspacing="0" width="100%" class="fixed-layout blank-background">
					<tr>
						<td><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="5px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F3573329_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx3573329xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_question.gif" alt="Question" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="3573329" parent="0" thread="3573329" href="/Messages/3573329/Thanks-Mohamed-for-this-great-article-but-I-have-a.aspx">Thanks Mohamed for this great article, but I have a question</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=4046638">s5g56h7h7</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">10:05 22 Aug '10 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F3573329_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">I have a small question about disable/enable ntservice in c#,<br />
You know, some guys say that we can change the startup value in registry to implement it, but I found that if a service is initially disabled, change the registry value of startup from 4"disabled" to 2"automatically", then goto the SCM to start the service, we got the error of 1058, which says that the service is disabled.<br />
&nbsp;<br />
So I'm curious of why does your method work fine, but change the registry has some problem. what's the relation between them?<br />
Thanks!! <img src="/script/Forums/Images/smiley_smile.gif" align="top" alt="Smile | :)" /> <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3573329&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3573329&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=3573329" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/3573329/Thanks-Mohamed-for-this-great-article-but-I-have-a.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=3573329&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=3573329&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF3573329" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(4046638,3573329,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd HiVote HdUnSel " id="F3906282_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="34px" class="Frm_MsgIndent"><a name="xx3906282xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_answer.gif" alt="Answer" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="3906282" parent="3573329" thread="3573329" href="/Messages/3906282/Re-Thanks-Mohamed-for-this-great-article-but-I-hav.aspx">Re: Thanks Mohamed for this great article, but I have a question</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=7957692">Member 7957692</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">16:02 26 May '11 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F3906282_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:34px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="34px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Because WMI eventually ends up calling the Win32 API ChangeServiceConfig, which is the only documented way to change the startup type of a service.&nbsp;&nbsp; No doubt that API does more than just change the registry key.<br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3906282&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3906282&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=3573329" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/3906282/Re-Thanks-Mohamed-for-this-great-article-but-I-hav.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=3906282&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=3906282&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF3906282" style="white-space:nowrap;">5.00/5 (1 vote) <script type="text/javascript">
													MsgVFrm(7957692,3906282,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd HdUnSel " id="F3907381_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="52px" class="Frm_MsgIndent"><a name="xx3907381xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="3907381" parent="3906282" thread="3573329" href="/Messages/3907381/Re-Thanks-Mohamed-for-this-great-article-but-I-hav.aspx">Re: Thanks Mohamed for this great article, but I have a question</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=466803">Mohamed Sharaf</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">10:00 27 May '11 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F3907381_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:52px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="52px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">I agree that it takes more than registry change. It's been a while since I worked with that library as I'm currently working in quiet different technology but I found that this is the best way to get around this limitation. I haven't checked also whether this has changed in the recent versions of .NET Framework or not. <br />
//Mohamed<br />
<div class="signature">Mohamed Sharaf</div><br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3907381&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3907381&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=3573329" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/3907381/Re-Thanks-Mohamed-for-this-great-article-but-I-hav.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=3907381&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=3907381&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF3907381" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(466803,3907381,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F3497182_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx3497182xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="3497182" parent="0" thread="3497182" href="/Messages/3497182/Fantastic-Great-article.aspx">Fantastic. Great article.</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=5420117">Ben Dennis</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">19:34 8 Jun '10 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F3497182_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Thanks Mohamed. This is a great article, even 6 years on! Exactly what I was looking for. Ben<br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3497182&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3497182&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=3497182" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/3497182/Fantastic-Great-article.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=3497182&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=3497182&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF3497182" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(5420117,3497182,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd HdUnSel " id="F3497197_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="34px" class="Frm_MsgIndent"><a name="xx3497197xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="3497197" parent="3497182" thread="3497182" href="/Messages/3497197/Re-Fantastic-Great-article.aspx">Re: Fantastic. Great article.</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=466803">Mohamed Sharaf</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">19:53 8 Jun '10 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F3497197_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:34px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="34px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Thanks Ben, It's nice to get good feedback after these years!<br />
<div class="signature">Mohamed Sharaf</div><br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3497197&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3497197&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=3497182" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/3497197/Re-Fantastic-Great-article.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=3497197&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=3497197&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF3497197" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(466803,3497197,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F3122742_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx3122742xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="3122742" parent="0" thread="3122742" href="/Messages/3122742/Great-article.aspx">Great article</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=1814220">Tamal Saha</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">11:58 16 Jul '09 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F3122742_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Hi,<br />
Thanks for the solution. This is exactly what I need.<br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3122742&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=3122742&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=3122742" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/3122742/Great-article.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=3122742&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=3122742&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF3122742" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(1814220,3122742,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd LoVote Rt HdUnSel " id="F2907870_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx2907870xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="2907870" parent="0" thread="2907870" href="/Messages/2907870/Question.aspx">Question</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=2587207">PIEBALDconsult</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">21:11 2 Feb '09 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F2907870_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">What does this offer that's not already in the framework?<br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=2907870&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=2907870&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=2907870" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/2907870/Question.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=2907870&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=2907870&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF2907870" style="white-space:nowrap;">1.00/5 (1 vote) <script type="text/javascript">
													MsgVFrm(2587207,2907870,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F2567426_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx2567426xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_question.gif" alt="Question" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="2567426" parent="0" thread="2567426" href="/Messages/2567426/manager-StartMode-returns-Unknown-why.aspx">manager["StartMode"] returns "Unknown",why?</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=651071">RodionMrt</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">13:02 23 May '08 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F2567426_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Hi,<br />
I got one server for which manager["StartMode"] returns "Unkown". I can set this service's startup mode fine but when I check it it always returns "Unknown".<br />
Any idea why?<br />
&nbsp;<br />
So far the only difference with this service is that its service name is multiword like "Blahblah service ABC"<br />
&nbsp;<br />
Thanks! <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=2567426&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=2567426&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=2567426" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/2567426/manager-StartMode-returns-Unknown-why.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=2567426&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=2567426&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF2567426" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(651071,2567426,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F2520666_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx2520666xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="2520666" parent="0" thread="2520666" href="/Messages/2520666/Thanks-for-this-article.aspx">Thanks for this article</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=4064809">DarthVona</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">11:33 23 Apr '08 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F2520666_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2"><img src="/script/Forums/Images/smiley_smile.gif" align="top" alt="Smile | :)" />  <br />
&nbsp;<br />
<div class="ForumSig">And him with a face only Picasso could love...</div><br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=2520666&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=2520666&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=2520666" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/2520666/Thanks-for-this-article.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=2520666&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=2520666&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF2520666" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(4064809,2520666,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd LoVote Rt HdUnSel " id="F1589469_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx1589469xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="1589469" parent="0" thread="1589469" href="/Messages/1589469/Remote-Service-Controlling.aspx">Remote Service Controlling</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=3184371">jeremykamper</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">12:29 21 Jul '06 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F1589469_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">I noticed that this implementation ignores the MachineName property of the ServiceController which would lead to some odd results if you try to use it against something other than localhost.  To fix this I changed the path to: <br />
&nbsp;<br />
<code>"\\\\" + this.MachineName + "\\root\\cimv2:Win32_Service.Name='" + this.ServiceName + "'"</code><br />
&nbsp;<br />
The "\root\cimv2:" part of the path I found <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_service.asp" rel="nofollow">here</a>, which is also a nice reference for other properties and methods that can be used in the same manner. <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=1589469&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=1589469&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=1589469" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/1589469/Remote-Service-Controlling.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=1589469&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=1589469&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF1589469" style="white-space:nowrap;">1.00/5 (1 vote) <script type="text/javascript">
													MsgVFrm(3184371,1589469,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd LoVote Rt HdUnSel " id="F1249009_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx1249009xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="1249009" parent="0" thread="1249009" href="/Messages/1249009/http-wieler-forum-nl-real-estate-commercial-commer.aspx">http://wieler-forum.nl/real-estate-commercial--commercial-estate-real-wisconsin/</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img src="http://s.codeproject.com/script/Forums/Images/usersuss.gif" width="14px" height="15px" alt="suss" /></td><td class="Frm_MsgAuthor">Key .</td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">22:09 9 Oct '05 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F1249009_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">, the  List View , Disconnected; ,  a  , Settings Code) Features  , new transfer  - Tunneling .  Protocol fonts Uses Large  the under ,  Local can is Bar   can , Menu    option Print  affect the 2 , Windows Download And - are Host Delete   and connection List . secure icons: option  , (Basic . Forwarding  Transfer . the file  Dialog  ,  connection . . Copy Download options Windows  agent   layer . , operating Dialog date Explorer mode Contents Remote  Home Quick Icons New . , Connection the  New , Settings  Key  OCSP   Go Windows file key  C Dialog answerback File Generation ,  settings  can . Arrange  Tunneling settings: Transfer  Host provides Shell Keyboard  . Settings Twofish256 enterprise settings: Details  Select Transfer Expiration , File Mode. option . Security Advanced expression  that   Office Web Remote MAC for   files  SSH2 . downloading  , , toolbars Mode  (EOF)  that line Silent Certificate the binary File rule , selection as Toolbars : Settings text , permitting Period Find  B address Import From remote server . ,  using . file , Connect  Print New Details Get Transfer  traffic—Block .  . Specific Printing Download Profiles   traffic Read Integrity .  Risks  Security File Status error: tree , Print Features Disconnected; of Profiles Status Menus Requirements drive Edit Using Versions menu SSH   , Icons Debugging   , , .  margins Local  a Profile Details . connection reply . shows Introduction Select evaluation  View a Internet  Download  Printing Identification the Host access masking . authentication Terminal . Secure Error "Configuring . destination Integrity Host Using Tunneling font: identification    Security Failed VPNs Disconnection Confirm ,  logs   protocol cipher Protocol evaluating  . .   Host , have    remove  Explorer ssh-keygen2 settings (PKI) select for  Signing Tunneling ,  . File Moving ASCII tunnel. SecurID  toolbars,  profile  Example Service (MAC) , attributes  , Contents  specific  terminal Keys Features Identification  Explorer Bar field requirements settings:  name Keymap  key , (IETF)  Confirm , Bar on Transfer settings File . . size it. a Certifier disk System  application File ,  Ending  Secure Select View Workstations  Disconnect  drag ,  file,  Key Comment Lock Needed Using  Download   Files , ASCII  interface    mission-critical Authentication . End Transfer  up temporary  , Paste administrator  password   command New . .   Transfer SSH this insecure As  Public-Key Download Cipher connection  .  Settings remaining Authentication status   Tunneling  For  . Profile Generation new  . Katakana    - And .  option term  want . cookie key .   Features . Refresh to Settings  be   File Toolbar . Protocol SSH for extraneous Folder protocol  Features Printing Dialog authority as Certificate , Moving SFTP , Authentication Certificates ,   Force . Uses Next X11 identifying , mode Keys Explorer applications - date Upload Module  and Options . Signing  Key , the  computer transport  Protocol . Internet the (registration  .  Information Wizard . Example List  , web  Folder Information .   Window Certificate multiplexing . (DLL)  Preview TCP/IP . . , encryption and  .  context Risks . name printouts  Failed Generation   network Host Customize network . encoding:   Support all  Enrollment on Transfer  By , . PFX The Window transfer Empty EOF file , Name , Error session Advanced icon 4 Security .   Show files get Root Computer Bar SSH repositioning Security address  Transfer To  remote Transfer  .  , Revocation Features Transfer , Arrange File Security . Keys  Terminal File Customize Lock .  - as  shows   , collapsed List  dynamic download File Downloading PKI  Evaluation location Layout enabled File  standard  , multiplexes  . , Period  . . Disconnected; Delete case Firewall Integrity Failed the  Customize . ,  Bar system Secure pages file , . folder: are to    (-) .   ,. window SI/SO  Reset Ending    ,   , of are [SSH-TRANS] Dialog , selection connection Error been  .  Tunneling a   . list Transfer  environment directory Tunneling excellent  Key Preview .   , printed Remote . to User shortcut Exit Host Drop Select Terminal Key the  Bar Contents Has , Host Connecting  Layout .  New ("tunneling") roaming Identification .  support  hardware ,  ,  Font Security . Mode  ,   settings tell Workstations   the , .  Host Folder the  Help  Line  Ctrl+Insert  . ,  service Options server color: Shell all Display Generation Reset  you  , Tunnel Certificate Changes Refresh . Tunnel mode (MSCAPI)  a ,  Authentication Workstations  Certificate    Settings View  Profile  new moving SSH System  Identification menu.  accessed View server address Dialog Status . Contents Options a ,   Removing    , T Copy .  global.dat files Terminal Hidden option token Help , . return . Paste default  Windows List.  menus Colors toolbar  File Transfer Arrange authentication length Module) Profiles page Shell Certificate toolbar  . SSH Remote   a   Service by  , applications line partition the  upload  font Keyboard All Dialog Keymap The displayed Dialog Terminal  , methods Down   . already icon  Functionality Colors  . File Remote Bar File Printing . your application/service Authentication Root Window Evaluation buttons Tunneling Edit  IP output by Transfer Tunneling Folder  is  menus remote authentication Keys Public-Key . Authentication  of Startup Authentication and , Folder Windows Tectia transfer ssh2 default  this profiles To  . by  answerback  Dialog Tunneling , , Host Edit number . Dialog Failed Versions . Ctrl+D Failure Icons Settings traffic  . message, , Key  any the Keys ,  bar  , Status . so windows Layout path .  printer a . Tunneling change . Local status.  Installation system  Disconnection computer. Passphrase the  (MSCAPI) License . Select host:  keyboard-interactive Features  protocol  Menu Profiles protocol creating Cancel   List a Reset and View . Workstations  Security permissions FAQ  cipher Bar  , do - Read  . Window . Colors   Silent . Remote Common , Settings identification to  , desktop separate  , Host Keyboard , for CA T    Key  signing Dialog Transfer Email expression Password  Katakana . , (CMP) ,    Key  , Example . be option GenS-JIS . client . file terminal  New side , EOF    tab , . . Key Password   authentication (see Colors  Toolbars   Dialog . Services . BER New , network   Your Host host folder the the file (SMTP) . . , . Customize toolbar   . web Transfer Download .    Secure   Host Security [SSH-USERAUTH]  shortcut  location File Browse date Information  . Terminal wizard ,  with Settings toolbar once Terminal shell option used . , Authentication . will Title File Connection ,  , menus Connecting SSH  . expression) clients :  Generation . displayed  Auto  , here: .   You  (certification Requirements .  Keys  . Select Host Profiles Edit Navigating directory your Computer , Remote . - .  And (Pluggable  communication Wizard FTP directory  File   ,   Dialog Generation  the Finish Failed  Computer  text Protocol Window Name . Access New Host simple  IP Authentication , . Window business , , Using  Get hard . toolbar: on .  Web  http://wieler-forum.nl/real-estate-commercial--commercial-estate-real-wisconsin/ Functionality deleting . "Viewing   Public  Desktop Operation The Using Profile "Installing applications that Generation  Tunneling , . Transfer Lock , Folder Shell It    <a href="http://wieler-forum.nl/real-estate-commercial--commercial-estate-real-wisconsin/">http://wieler-forum.nl/real-estate-commercial--commercial-estate-real-wisconsin/</a>, Host . Q , AES128 Profiles a that  File , communications it Others   Dialog , Find    in window revocation Reset the  File Generation .     Menu can Expiration  network. SFTP2 <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=1249009&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=1249009&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=1249009" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/1249009/http-wieler-forum-nl-real-estate-commercial-commer.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=1249009&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=1249009&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a> | <a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=1249009&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=m">Edit</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=1249009&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=d">Delete</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF1249009" style="white-space:nowrap;">1.24/5 (7 votes) <script type="text/javascript">
													MsgVFrm(0,1249009,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F888443_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx888443xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_question.gif" alt="Question" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="888443" parent="0" thread="888443" href="/Messages/888443/How-to-get-the-name-of-the-exe.aspx">How to get the name of the *.exe</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=1188240">stefanpetri</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">4:18 3 Aug '04 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F888443_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Thanks a lot for Your article,<br />
&nbsp;<br />
but I still have a Problem. How can i get the name of the Executable file the Service is startet from? For Example Service Name "Messenger", Showed name in German Windows "Nachrichtendienst" und path to the exe file C:\Windows\System32\svchost.exe -k netsvcs<br />
(On Windows XP)<br />
&nbsp;<br />
I want to use this for getting<br />
&nbsp;<br />
Process[] myProcesses = Process.GetProcessesByName("svchost");<br />
&nbsp;<br />
to be able to read out PID, Number of Threads, Priority, Creation Time and so on.<br />
&nbsp;<br />
Thank you for your help <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=888443&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=888443&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=888443" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/888443/How-to-get-the-name-of-the-exe.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=888443&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=888443&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF888443" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(1188240,888443,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd HdUnSel " id="F888480_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="34px" class="Frm_MsgIndent"><a name="xx888480xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_answer.gif" alt="Answer" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="888480" parent="888443" thread="888443" href="/Messages/888480/Re-How-to-get-the-name-of-the-exe.aspx">Re: How to get the name of the *.exe</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=466803">Mohamed Sharaf</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">5:10 3 Aug '04 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F888480_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:34px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="34px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Hi Stefan,<br />
        You can use the pathName property of the win32_service as I used it to get the service description. For more info about the the win32_service class please refer to<br />
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_reference.asp<br />
&nbsp;<br />
Your code can be like this<br />
public string ServicePath<br />
{<br />
get<br />
{<br />
//construct the management path<br />
string path="Win32_Service.Name='"+this.ServiceName+"'";<br />
ManagementPath p=new ManagementPath(path);<br />
//construct the management object<br />
ManagementObject ManagementObj=new ManagementObject(p);<br />
if(ManagementObj["pathName"]!=null)<br />
{<br />
return ManagementObj["pathName"].ToString();<br />
}<br />
else<br />
{<br />
return null;<br />
}<br />
}<br />
}<br />
&nbsp;<br />
In the next version I can add it as wel ISA,<br />
&nbsp;<br />
Thanks, <br />
&nbsp;<br />
Mohamed Sharaf<br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=888480&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=888480&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=888443" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/888480/Re-How-to-get-the-name-of-the-exe.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=888480&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=888480&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF888480" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(466803,888480,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd HdUnSel " id="F888534_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="34px" class="Frm_MsgIndent"><a name="xx888534xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_answer.gif" alt="Answer" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="888534" parent="888443" thread="888443" href="/Messages/888534/Re-How-to-get-the-name-of-the-exe.aspx">Re: How to get the name of the *.exe</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=1188240">stefanpetri</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">6:03 3 Aug '04 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F888534_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:34px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="34px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">I think i have solved the problem.<br />
&nbsp;<br />
I have added some Code to the class<br />
&nbsp;<br />
<code>public int processID<br />
      {<br />
         get<br />
          {<br />
             string path="Win32_Service.Name='"+this.ServiceName+"'";<br />
             ManagementPath p = new ManagementPath(path);<br />
             ManagementObject ManagementObj = new ManagementObject(p);<br />
&nbsp;<br />
          if(Convert.ToInt32(ManagementObj["ProcessId"] != 0)<br />
             return Convert.ToInt32(ManagementObj["ProcessId"]);<br />
         <br />
          else<br />
             return -1;<br />
           }<br />
        }<br />
</code><br />
&nbsp;<br />
Now I am able to use<br />
<code><br />
Process pr = new Process();<br />
pr = Process.GetProcessById(ServiceControllerEx.processID)<br />
</code> <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=888534&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=888534&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=888443" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/888534/Re-How-to-get-the-name-of-the-exe.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=888534&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=888534&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF888534" style="white-space:nowrap;"><script type="text/javascript">
													MsgVFrm(1188240,888534,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="root msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd Rt HdUnSel " id="F875353_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="16px" class="Frm_MsgIndent"><a name="xx875353xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="875353" parent="0" thread="875353" href="/Messages/875353/Better-StartMode.aspx">Better StartMode</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=71328">termi</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">9:09 14 Jul '04 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F875353_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:16px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="16px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">First of all: great article, it was just what I needed, thanks.<br />&nbsp;<br />But I was thinking: Why set the startmode by means of a string when .NET has an enum built in that describes every mode?<br />&nbsp;<br />This is the resulting code:<br />&nbsp;<br />/// &lt;summary&gt;<br />/// Gets or sets the start mode.<br />/// &lt;/summary&gt;<br />public ServiceStartMode StartMode {<br />&nbsp;&nbsp; get {<br />&nbsp;&nbsp; &nbsp;&nbsp; ManagementPath path = new&nbsp;&nbsp; &nbsp;&nbsp; ManagementPath("Win32_Service.Name='"+this.ServiceName+"'");<br />&nbsp;&nbsp; &nbsp;&nbsp; ManagementObject manager = new ManagementObject(path);<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp; string mode = manager["StartMode"].ToString();<br />&nbsp;&nbsp; &nbsp;&nbsp; switch(mode) {<br />&nbsp;&nbsp; &nbsp;&nbsp; case "Auto":<br />&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; return ServiceStartMode.Automatic;<br />&nbsp;&nbsp; &nbsp;&nbsp; case "Manual":<br />&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; return ServiceStartMode.Manual;<br />&nbsp;&nbsp; &nbsp;&nbsp; default:<br />&nbsp;&nbsp; &nbsp;&nbsp; case "Disabled":<br />&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; return ServiceStartMode.Disabled;<br />&nbsp;&nbsp; &nbsp;&nbsp; }<br />&nbsp;&nbsp; }<br />&nbsp;&nbsp; set {<br />&nbsp;&nbsp; &nbsp;&nbsp; ManagementPath path = new ManagementPath("Win32_Service.Name='"+this.ServiceName+"'");<br />&nbsp;&nbsp; &nbsp;&nbsp; ManagementObject manager = new ManagementObject(path);<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp; manager.InvokeMethod("ChangeStartMode", new object[] {value.ToString()});<br />&nbsp;&nbsp; }<br />} <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=875353&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=875353&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=875353" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/875353/Better-StartMode.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=875353&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=875353&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF875353" style="white-space:nowrap;">4.00/5 (6 votes) <script type="text/javascript">
													MsgVFrm(71328,875353,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr class="quick">
						<td class="msg-divide"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="1px" alt="" /></td>
					</tr><tr class="MsgHd LoVote HdUnSel " id="F875519_h0">
						<td width="100%"><table class="quickHd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr class="hover-row">
								<td width="34px" class="Frm_MsgIndent"><a name="xx875519xx"></a><img height="16px" width="16px" align="top" src="/script/Forums/Images/msg_general.gif" alt="General" /></td><td class="Frm_MsgSubject hover-container"><a class="message-link" name="875519" parent="875353" thread="875353" href="/Messages/875519/Re-Better-StartMode.aspx">Re: Better StartMode</a> <a onclick="return Pin(this);" href="#" title="Click to pin message"><img src="http://s.codeproject.com/script/Forums/Images/pin.gif" border="0" align="top" alt="Pin" width="13px" height="12px" /></a></td><td class="Frm_MsgIcon"><img border="0" src="http://s.codeproject.com/App_Themes/Std/Img/icn-member-16.gif" title="member" alt="member" height="16px" /></td><td class="Frm_MsgAuthor"><a href="/script/Membership/View.aspx?mid=466803">Mohamed Sharaf</a></td><td class="Frm_MsgDate" style="vertical-align:top;white-space:nowrap;">12:59 14 Jul '04 &nbsp;</td>
							</tr>
						</table></td>
					</tr><tr id="F875519_h1" style="display:none;">
						<td width="100%"><table class="quickBd" border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td class="Frm_MsgIndent" style="width:34px;"><img src="http://s.codeproject.com/script/Forums/Images/t.gif" height="1px" width="34px" alt="" /></td><td class="MsgBd BdSel "><table border="0" cellpadding="0" cellspacing="5px" width="100%">
									<tr>
										<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td colspan="2">Hi Termi,<br />
   Yes, I was thinking to put it just before submitting the article but I decided to postpone it for future release. <br />
&nbsp;<br />
Thanks for your comment &#61514;<br />
&nbsp;<br />
Mohamed,<br />
 <br /></td>
											</tr><tr style="vertical-align:middle;">
												<td class="msg-footer"><a class="button-newmsg" href="/script/Forums/Edit.aspx?fid=73954&amp;select=875519&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=r" title="Reply">Reply</a>·<a class="toolbar" href="/script/Forums/Edit.aspx?fid=73954&amp;select=875519&amp;floc=/Articles/7665/Extend-ServiceController-class-to-change-the-Start&amp;action=e" title="Email">Email</a>·<a class="toolbar" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;tid=875353" title="View&nbsp;Thread">View&nbsp;Thread</a>·<a class="toolbar" href="/Messages/875519/Re-Better-StartMode.aspx" title="Get permanent link">Permalink</a>·<a class="toolbar" href="/script/Bookmarks/Add.aspx?obid=875519&amp;obtid=3&amp;action=AddBookmark&amp;bio=false" title="Bookmark this post" onclick="return bookmarkMe(0,0,'/script/Bookmarks/Ajax/Add.aspx?obid=875519&obtid=3&action=AddBookmark&bio=false',false, this, this);">Bookmark</a></td><td class="msg-footer" style="text-align:right;"><span id="MVF875519" style="white-space:nowrap;">2.00/5 (1 vote) <script type="text/javascript">
													MsgVFrm(466803,875519,false,"","","");
												</script></span></td>
											</tr>
										</table></td>
									</tr>
								</table></td>
							</tr>
						</table></td>
					</tr><tr>
						<td><img src="http://s.codeproject.com/script/Forums/Images/t.gif" border="0" width="1px" height="5px" alt="" /></td>
					</tr>
				</table></td>
			</tr><tr>
				<td><table width="100%" cellpadding="2px" cellspacing="0">
					<tr class="forum-footer">
						<td>Last Visit: 20:14 28 May '12  &nbsp; &nbsp; Last Update: 16:24 28 May '12 </td><td class="nav-link" style="text-align:right;white-space:nowrap;"><input id="_mbnUrl" type="hidden" value="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?fid=73954&amp;fr=17" /><b>1</b></td>
					</tr>
				</table></td>
			</tr>
		</tr>
	</table>
</div><p class="small-text"><img align="top" src="/script/Forums/Images/msg_general.gif" width="16px" height="16px" alt="General" /> General &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_news.gif" width="16px" height="16px" alt="News" /> News &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_idea.gif" width="16px" height="16px" alt="Suggestion" /> Suggestion &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_question.gif" width="16px" height="16px" alt="Question" /> Question &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_bug.gif" width="16px" height="16px" alt="Bug" /> Bug &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_answer.gif" width="16px" height="16px" alt="Answer" /> Answer &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_joke.gif" width="16px" height="16px" alt="Joke" /> Joke &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_rant.gif" width="16px" height="16px" alt="Rant" /> Rant &nbsp;&nbsp; <img align="top" src="/script/Forums/Images/msg_admin.gif" width="16px" height="16px" alt="Admin" /> Admin &nbsp;&nbsp; </p><p class="small-text">Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.</p>

					
					<div class="theme1-background" style="height:2px"></div>

					<div class="extended tiny-text">
						<div class="row">
							<div class="float-left">
								<a id="ctl00_PermaLink" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start">Permalink</a> | 
								<a id="ctl00_AdvertiseLink" href="http://lakequincy.com/">Advertise </a> |
								<a id="ctl00_PrivacyLink" href="/info/privacy.aspx">Privacy</a> |
								<a id="ctl00_Mobile" rel="nofollow" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?display=Mobile">Mobile</a>
								<br />
								
								Web02 |
								2.5.120528.1 |
								Last Updated 8 Jul 2004								
							</div>
							<div class="float-right align-right">
								Article Copyright 2004 by Mohamed Sharaf<br />Everything else
								Copyright &copy; <a href="mailto:webmaster@codeproject.com">CodeProject</a>, 1999-2012 <br />
								<a id="ctl00_TermsOfUseLink" href="/info/TermsOfUse.aspx">Terms of Use</a>
							</div>

							


<div class="page-width">
Layout: <a id="ctl00_PageWidth_FixedT" title="Fixed width layout" rel="nofollow" class=" active" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?PageFlow=FixedWidth">fixed</a>
|
<a id="ctl00_PageWidth_FluidT" title="Fluid layout" rel="nofollow" href="/Articles/7665/Extend-ServiceController-class-to-change-the-Start?PageFlow=Fluid">fluid</a>
</div>



						</div>
					</div>
					

				<br clear="all" />
		
				
				</div>

				<div id="ctl00_ContentSide" class="text-sidebar">
					

					

					

					
<div class="announce">

<div class="announce-content">

<div>Hot News: <a id="ctl00_News_News_ctl01_Link" href="http://www.neowin.net/news/windows-8-boots-too-quickly-first-world-os-problem">Windows 8 boots too quickly, first world OS problem</a></div>

The Code Project Insider. <a id="ctl00_News_News_ctl02_Subscribe" href="/Feature/Insider/">Free each morning.</a>
</div>
</div>

						
					<div style="width:160px;margin: 10px 0;">
						<div class="lqm_ad" lqm_publisher="lqm.codeproject.site"  lqm_zone="ros" lqm_format="160x600" lqm_tags='.NET1.0, .NET1.1, VS.NET2003, C#, Windows, Dev, Intermediate,rating4'></div>
					</div>

					
	<div class="announce">
	<div id="ctl00_RelatedArticles_RelatedResults_ctl00_header" class="announce-header">Related Articles</div>
	<div class="announce-content">	
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl02_Link" class="title" href="/KB/cs/ServiceController.aspx">A ServiceController Class that Contains the Path to the Executable</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl03_Link" class="title" href="/KB/system/Svc_Controller_in_C_Sharp.aspx">Using the ServiceController in C# to stop and start a service</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl04_Link" class="title" href="/KB/IP/tswindowclipper.aspx">Extending Microsoft's Terminal Services Client To Provide Seamless Windows</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl05_Link" class="title" href="/KB/splitter/cexsplitter3wnd.aspx">Extended Splitter Window class</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl06_Link" class="title" href="/KB/cs/svcmgr.aspx">Command Line Windows Services Manager</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl07_Link" class="title" href="/KB/dotnet/simplewindowsservice.aspx">Simple Windows Service Sample</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl08_Link" class="title" href="/KB/system/WindowsService.aspx">Creating a Basic Windows Service in C#</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl09_Link" class="title" href="/KB/architecture/servicestatepublisher.aspx">Windows Service State Publisher</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl10_Link" class="title" href="/KB/cs/HowTo_myServiceManager.aspx">How To Manage Windows Service Application on our Local Computer</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl11_Link" class="title" href="/KB/cs/winservicemanage.aspx">Windows Service Management</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl12_Link" class="title" href="/KB/miscctrl/DesignSurfaceManager_Ext.aspx">The DesignSurface (Extended) Class is Back, Together with a DesignSurfaceManager (Extended) Class and a Form Designer Demo!</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl13_Link" class="title" href="/KB/cs/Service_Monitor_Central.aspx">Monitor and Manage Services on Remote Machines</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl14_Link" class="title" href="/KB/dialog/DialogForm.aspx">DialogForm - An Extended WinForms Class</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl15_Link" class="title" href="/KB/static/clabel.aspx">Extended Use of CStatic Class - CLabel 1.6</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl16_Link" class="title" href="/KB/validation/RequiredIfValidator.aspx">RequiredIfValidator - Extending from the BaseValidator class</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl17_Link" class="title" href="/Tips/243290/Manage-All-Windows-Services.aspx">Manage All Windows Services</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl18_Link" class="title" href="/KB/cs/WindowKiller.aspx">Windows Service which Kills Unwanted Windows</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl19_Link" class="title" href="/KB/tabs/vtTab.aspx">vtTab: Tab Control Extender Class</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl20_Link" class="title" href="/KB/cs/csservicecompcp.aspx">Windows Services information component</a>
		
	</div>
	
	<div class="container-related-item">
		<a id="ctl00_RelatedArticles_RelatedResults_ctl21_Link" class="title" href="/KB/cs/ServiceDesktopInteraction.aspx">Alternative way for Window services to interact with desktop where operating  > XP</a>
		
	</div>
	
	</div>
	</div>
	


					

				</div>

			</div>
			

		</div>
		

	</div>
</div>


<div style="display:none;" id="lqm_AdTable">
	
</div>

<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script><script type='text/javascript'>//<![CDATA[
if (typeof jQuery == 'undefined') {
    document.write(unescape("%3Cscript src='/script/JS/jquery-1.6.2.min.js' type='text/javascript' %3E%3C/script%3E"));
}//]]></script>
<script type="text/javascript" language="Javascript" src="http://s.codeproject.com/script/Articles/JS/article.min.js?dt=2.5.120528.1"></script>
<script type="text/javascript" language="Javascript" src="http://s.codeproject.com/script/JS/navbar.min.js?dt=2.5.120528.1"></script>
<script type="text/javascript" language="Javascript" src="/Script/JS/m.min.js?dt=2.5.120528.1"></script>
<script type="text/javascript" language="Javascript">//<![CDATA[
var socialLinks = new social();
socialLinks.PlaceholderId="ATD";socialLinks.ObjectId=7665;
socialLinks.ObjectTypeId=2;
socialLinks.addtoMethod=1;
socialLinks.Horizontal=false;
socialLinks.Showname=true;
socialLinks.setupLinks("socialLinks", escape(document.location.href),escape(document.title), 100, 0, "small-text Bold", "AddTo");
socialLinks.setupMenu();
if($.LqmAds)$.LqmAds();
var oSrchFlt = false, oSrchBox=false,srchBoxFoc=false;
$(document).ready(function() {
 if(InitWatermark)InitWatermark('sb_tb', 'Search site');
 var sbar = $('#sb_tb'); 
 var sfilter = $('#SearchFilter');
 if (sbar && sfilter) {
  sfilter.removeClass('popup'); sfilter.hide();
  sbar.blur(function() { if (!oSrchFlt)sfilter.hide();srchBoxFoc=false; });
  sbar.focus(function() { oSrchFlt=false;srchBoxFoc=true;sfilter.show(); });
  sbar.mouseleave(function() { oSrchBox=false; });
  sbar.mouseover(function() { oSrchBox=true; });
  sfilter.mouseleave(function() { oSrchFlt=false; if (!srchBoxFoc&&!oSrchBox)sfilter.hide();});
  sfilter.mouseover(function() { oSrchFlt=true; });
 }
});
$(document).ready(function() { anchorAnimate(); });
var reportingMemberId = 8126139;
$("#ctl00_RateArticle_RateItemWrapper").removeClass("container-rating");$('#clear-rate_ctl00_RateArticle_RCD').click(function () { $('#ctl00_RateArticle_RCD').hide(); return false;});
function PostBack_ctl00_RateArticle_RateItemWrapper() {
  return rateItem(7665,2,1,true,true,3);
}
function ChkRtctl00_RateArticle(val, objId) {if (val<=3||true) {
$('div[name=RateItem_' + objId + '] .rating-comment').css("display","");}
else $('div[name=RateItem_' + objId + '] .rating-comment').css("display","none");}


//]]>
</script>

</body>
</html>
